public class ShimPluginRegistry extends Object implements PluginRegistry
PluginRegistry
that is shimmed to let old plugins use the new Android embedding and
plugin API behind the scenes.
The following is an example usage of ShimPluginRegistry
within a FlutterActivity
:
// Create the FlutterEngine that will back the Flutter UI. FlutterEngine flutterEngine = new FlutterEngine(context); // Create a ShimPluginRegistry and wrap the FlutterEngine with the shim. ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine, platformViewsController); // Use the GeneratedPluginRegistrant to add every plugin that's in the pubspec. GeneratedPluginRegistrant.registerWith(shimPluginRegistry);
PluginRegistry.ActivityResultListener, PluginRegistry.NewIntentListener, PluginRegistry.PluginRegistrantCallback, PluginRegistry.Registrar, PluginRegistry.RequestPermissionsResultListener, PluginRegistry.UserLeaveHintListener, PluginRegistry.ViewDestroyListener
Constructor and Description |
---|
ShimPluginRegistry(FlutterEngine flutterEngine) |
Modifier and Type | Method and Description |
---|---|
boolean |
hasPlugin(String pluginKey)
Returns whether the specified plugin is known to this registry.
|
PluginRegistry.Registrar |
registrarFor(String pluginKey)
Returns a
PluginRegistry.Registrar for receiving the registrations pertaining to the specified plugin. |
<T> T |
valuePublishedByPlugin(String pluginKey)
Returns the value published by the specified plugin, if any.
|
public ShimPluginRegistry(@NonNull FlutterEngine flutterEngine)
public PluginRegistry.Registrar registrarFor(String pluginKey)
PluginRegistry
PluginRegistry.Registrar
for receiving the registrations pertaining to the specified plugin.registrarFor
in interface PluginRegistry
pluginKey
- a unique String identifying the plugin; typically the fully qualified name of
the plugin's main class.public boolean hasPlugin(String pluginKey)
PluginRegistry
hasPlugin
in interface PluginRegistry
pluginKey
- a unique String identifying the plugin; typically the fully qualified name of
the plugin's main class.public <T> T valuePublishedByPlugin(String pluginKey)
PluginRegistry
Plugins may publish a single value, such as an instance of the plugin's main class, for situations where external control or interaction is needed. Clients are expected to know the value's type.
valuePublishedByPlugin
in interface PluginRegistry
pluginKey
- a unique String identifying the plugin; typically the fully qualified name of
the plugin's main class.