Class ShimPluginRegistry

  • All Implemented Interfaces:
    PluginRegistry

    public class ShimPluginRegistry
    extends Object
    implements PluginRegistry
    A 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);
     
    • Constructor Detail

      • ShimPluginRegistry

        public ShimPluginRegistry​(@NonNull
                                  FlutterEngine flutterEngine)
    • Method Detail

      • hasPlugin

        public boolean hasPlugin​(@NonNull
                                 String pluginKey)
        Description copied from interface: PluginRegistry
        Returns whether the specified plugin is known to this registry.
        Specified by:
        hasPlugin in interface PluginRegistry
        Parameters:
        pluginKey - a unique String identifying the plugin; typically the fully qualified name of the plugin's main class.
        Returns:
        true if this registry has handed out a registrar for the specified plugin.
      • valuePublishedByPlugin

        public <T> T valuePublishedByPlugin​(@NonNull
                                            String pluginKey)
        Description copied from interface: PluginRegistry
        Returns the value published by the specified plugin, if any.

        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.

        Specified by:
        valuePublishedByPlugin in interface PluginRegistry
        Type Parameters:
        T - The type of the value.
        Parameters:
        pluginKey - a unique String identifying the plugin; typically the fully qualified name of the plugin's main class.
        Returns:
        the published value, possibly null.