- Have your
.proto
file handy with you
// This is a sample proto file, present at lib/proto/model.proto
syntax = "proto3";
message GExerciseModel
{
string exercise_name = 2;
GLEDLogic led_logic = 3;
int32 blazepods = 4;
int32 duration = 5;
optional int32 sets = 6;
optional int32 timeout = 7;
optional int32 interval_between_sets = 8;
GInteraction interaction = 9;
optional string active_color = 10;
string id = 11;
optional bool count = 12;
optional bool missing_count = 13;
optional double distance = 14;
}
enum GInteraction {
G_INTERACTION_TAP_SPECIFIC_COLOR = 0;
G_INTERACTION_TAP_SEQUENCE = 1;
G_INTERACTION_DISTANCE_CHANGE = 2;
}
enum GLEDLogic {
G_L_E_D_LOGIC_RANDOM = 0;
G_L_E_D_LOGIC_ALL_AT_ONCE = 1;
G_L_E_D_LOGIC_FOCUS = 2;
G_L_E_D_LOGIC_HOME_BASE = 3;
G_L_E_D_LOGIC_SEQUENCE = 4;
}
- Dependencies Required 1
dependencies:
protobuf: ^2.1.0
dart pub global activate protoc_plugin
- Generate Your Classes
cd lib/models &&
protoc --dart_out=. *.proto
After this 4 files will be created in your lib/models/
You can now use this to create objects
- Refer the example in
lib/main.dart
to get started It also includes converting ENUMS from different types