Skip to content

Use a common PluginPlatformInterfaceMixin in federated plugins #43368

@amirh

Description

@amirh

The platform interfaces for federated plugins include some logic other than the interface definition (see flutter/plugins#2230).

We would like to move the common code to a reusable place such that a federated plugin platform interface looks like:

class UrlLauncherPlatform with PluginPlatformInterfaceMixin {

// The only thing we have here is the interface definition in the form of throwing methods, e.g:

  Future<bool> canLaunch(String url) {
    throw UnimplementedError('canLaunch() has not been implemented.');
  }

}

Note that this means removing the static instance from the platform interface, and instead keeping some central map of platform implementations.

Platform implementation activation will look something like:

// We may be able to do more useful things than having a public static instance, but
// this is out of scope for current discussion.
PluginImplementations pluginImplementations = PluginImplementations.instance;
pluginImplementations.set(UrlLauncherPlatform, WindowsUrlLauncherPlatform());

cc @collinjackson @hterkelsen @stuartmorgan @franciscojma86

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions