The author uses Flutter for UI, Golang binary for the app backend, and uses channels passing serialized protobuf messages between them. Since adding a new API call requires changes in multiple places, they ended up defining a "god message" which has a oneof with all possible options:
message CarrotAPI {
oneof api {
Function1API function1 = 10;
Function2API function2 = 11;
}
}
message Function1API {
message Request {}
message Response {}
Request request = 1;
Response response = 2;
}
and then dispatch the call using switch to check the value of the api field.This is... not really a good API design. I wonder if the problem of "multiple places to be edited" can be solved in an easier way by making a custom protoc plugin [1] which will take care of generating all the boilerplate for both Dart and Golang. This is how support for new languages and use cases is normally added to protoc.
I don’t get it. Why not just use dart for the app backend? I understand not using it on the server because it’s not mature there.