I'm currently building a Plugin to make use of native API's on Android and iOS.
I've written MyPlugin which implements MethodCallHandler. In my plugin project, I have an example app. This example app has a generated class GeneratedPluginRegistrant.class, which calls the static method registerWith. All of this is used as a one liner in the MainActivity.
I have several questions.
It seems that MyPlugin must match the name of the plugin project. IE - project is flutter_tools, my plugin must be named FlutterToolsPlugin, otherwise GeneratedPluginRegistrant will break. How is GeneratedPluginRegistrant generated?
What is the purpose of GeneratedPluginRegistrant?
What is actually happening to my plugin when it is registered?
If I want to use MyPlugin, can it be done so without the GeneratedPluginRegistrant? I wish to respond to lifecycle methods like onActivityResult, and it seems this encapsulation prevents me from interacting with the plugin directly in the FlutterActivity.
Can I interact with other native plugins from my own on the native side without having to go back and forth through Dart?
The GeneratedPluginRegistrant is automatically generated by a FlutterApplication in order to register plugins defined in your Flutter App's pubspec.yaml file.
Show activity on this post. activity = binding. activity; should be activity = binding. getActivity(); Else code works great for me!
generated_plugin_registrant. dart is an automatically generated file that is required to compile your Flutter project as a web application: This file generated_plugin_registrant. dart exists only to support the web. It exists if Flutter is web-enabled and there is at least one package that has asked for it.
The GeneratedPluginRegistrant is automatically generated by a FlutterApplication in order to register plugins defined in your Flutter App's pubspec.yaml file. By providing an instance of PluginRegistry like FlutterActivity to the GeneratedPluginRegistrant#registerWith function you enable interactions between your Flutter Plugins and your Android APIs. see @PluginRegistry Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With