-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pigeon] Better documentation for @FlutterApi usage #108531
Comments
This isn't entirely accurate. See https://pub.dev/packages/pigeon#calling-into-flutter-from-the-host-platform Nonetheless, more documentation is always good. |
Sorry, yeah, I missed that. I updated the issue. |
Yes, that Twilio example is pretty good. On my host (iOS Swift) side I was doing flutterApi = MyPluginFlutterApi(binaryMessenger: registrar.messenger()) and therefore nothing was getting called on the Flutter side! (Going over the Twilio example pointed that out to me, but a quick README example would have been much faster/easier to find.) The generated Pigeon code allows me to instantiate the FlutterApi without a binary messenger, which was why it wasn't working -- And had to figure out how to extend the MyPluginFlutterApi on the Dart side as well. But there, it uses the default binary messenger in Flutter -- but it obviously can't do that on the host side and needs to be instantiated with it. In both places, it needs to be " MyPluginFlutterApi.setup(MyPluginFlutterApiImpl(instance: this)); Pigeon is amazing! Respectfully, I would not regard the small paragraph stating one can use |
Pigeon is really amazing and easy to use, but its poor documentation makes it very tricky. I just created a plugin a found multiple issues that were not touched by the documentation. Even the example repository provided is not up to date, implementing the version Note that lots of Flutter devs don't have experience with native code, so more complete examples would be much appreciated. |
checkout this blog for more info on using |
I am also not able to do native to flutter communication on android using java. |
@learncodingforweb The webview_flutter plugin uses Pigeon. I was learning myself how to use it and found this a great example to learn from. |
Updates README's to better reflect modern pigeon and it's usage. Very open to feedback on this, please let me know what could be better, clearer, or is just missing from this documentation. I don't expect to be able to cover all uses with this, if people want to see all possibilities, I think looking into our very thorough integration tests will provide them with anything they could need (all of which is linked in the example README). fixes flutter/flutter#66511 partial work for flutter/flutter#123851 fixes flutter/flutter#108531 fixes flutter/flutter#92641
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Use case
The documentation and example of pigeon describe the usage of
@HostApi
, which is used to call into native code from flutter.But Pigeon also supports
@FlutterApi
, which enables the native code to call into Flutter code, typically used for Steam-like updates that are not initiated from the Flutter side, but from the OS/native side.This feature is
not mentionedonly briefly in the README and there are no examples that showcase it.Proposal
Pigeon should have better documentation for
@FlutterApi
in the README and either add an example project or at least link to a third-party package that uses it.In a quick search I only found these third-party projects using it:
The text was updated successfully, but these errors were encountered: