You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matej Drobnič edited this page Dec 28, 2020
·
2 revisions
App uses pigeon package to generate type-safe communication messages.
Interfaces are defined in pigeons.dart file. Adding interfaces to that file and regenerating Pigeons (see README for instructions on that) will generate pigeons.g.dart on dart side and Pigeons.java on Android side. Those generated calls can then be used to call methods on each other side.
Caveats:
Pigeon methods can only accept and return classes. To use primitive type as argument or return type, use one of the available wrapper classes (NumberWrapper, BooleanWrapper etc.)
Pigeon does not support generics. That is why manually convert objects from/to maps when sending list of objects over Pigeon (for example see PebbleScanDevice.
Flutter side
To use Flutter -> Native pigeon, just construct it and call its methods (for example UiConnectionControl().connectToWatch(address);).
Tu use Native -> Flutter pigeon, implement the interface and then call MyInterface.setup(implementation);. Make sure that you call MyInterface.setup(null); whenever object that implements the interface is disposed to not leak memory.
It is recommended that you create a wrapper class that transforms pigeons into nicer classes that can used via hooks. For example see connectionStateProvider.