Skip to content

Eliminate use of shared method channels in flutter/plugins #94224

@stuartmorgan-g

Description

@stuartmorgan-g

Per the approved https://docs.flutter.dev/go/platform-channels-in-federated-plugins the plan of record is to move all of the 1P plugins away from using the shared method channel implementations that live in the _platform_interface packages.

This can be done for desktop platforms starting now, and for mobile platforms starting once version 2.8 or later reaches stable (when auto-registration becomes available for mobile).

This is fairly straightforward, so would be a good candidate for someone interested in learning the process of contributing to flutter/plugins. The process for an initial conversion is (note that this assumes familiarity with federated plugins):

  • Pick a package that hasn't been converted. The simplest case is a federated implementation package that doesn't contain a lib directory. (We could potentially also do this for app-facing packages that still contain the mobile implementations.)
  • Create a new <PluginName><Platform> Dart class by duplicating the existing method channel implementation from the platform interface package.
  • Add a registerWith() method to it that registers it as the default instance
  • Add that class as a dartPluginClass to the relevant plugin platform in the pubspec.yaml.
  • Rename the channel, on both the Dart and the native side (to ensure that the right Dart implementation is in fact being used).
  • Duplicate the method channel unit tests from the platform interface package into the platform implementation package, adjusting it to test the new class.
    • Add a unit test that registerWith() registers the platform interface instance.
  • Ensure that the package requires 2.5+ if desktop, or 2.8+ if mobile.

In some cases there are minor follow-up adjustments to make. E.g., if a method isn't relevant to that platform, it can be removed from the method channel entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: contributor-productivityTeam-specific productivity, code health, technical debt.packageflutter/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