protobuf_message_editor 0.0.3 copy "protobuf_message_editor: ^0.0.3" to clipboard
protobuf_message_editor: ^0.0.3 copied to clipboard

An editor widget for protobuf GeneratedMessage instances

A general protobuf message (GeneratedMessage) editor. Note that this only works with material apps as it relies on material widgets.

Features #

Given a GeneratedMessage instance, ProtoMessageEditor and ProtoDualPanelMessageEditor can be used to edit the message. Do note that this still requires the protobuf definition to be present and the dart code to be generated.

Getting started #

Install the package:

flutter pub add protobuf_message_editor

Usage #

There are two main widgets provided by this package:

ProtoMessageEditor #

Simple editor with expansion tiles for submessages:

Widget build(context) {
  final message = YourGeneratedMessage();

  return SingleChildScrollView(
    child: ProtoMessageEditor(message: message),
  );
}

ProtoDualPanelMessageEditor #

Dual panel editor with navigation support for nested messages:

late final GeneratedMessage _rootMessage;
late final ProtoNavigationState _navigationState;

@override
initState() {
  super.initState();
  _rootMessage = YourGeneratedMessage();
  _navigationState = ProtoNavigationState.fromRootMessage(_rootMessage);
}

@override
dispose() {
  _navigationState.dispose();

  super.dispose();
}

Widget build(context) {
  // With a manually created navigation state
  return ProtoDualPanelMessageEditor(
    navigationState: _navigationState,
  );

  // Or with a root message
  // The widget will create an internally managed navigation state, and dispose
  // of it when the widget is disposed.
  return ProtoDualPanelMessageEditor.withRootMessage(
    rootMessage: _rootMessage,
  );
}

See the /example folder for a complete working example with both editors.

Additional information #

This was meant to be a quick and dirty internal tooling solution for one of my projects, but ended up needing this for other projects as well. It's probably quite buggy and not well-tested, doesn't have any real documentation outside of the simple examples, and is definitely not production ready.

0
likes
140
points
188
downloads

Publisher

unverified uploader

Weekly Downloads

An editor widget for protobuf GeneratedMessage instances

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

collection, fixnum, flutter, intersperse, protobuf, provider

More

Packages that depend on protobuf_message_editor