-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
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
libdirectory. (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
dartPluginClassto the relevantpluginplatformin 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 interfaceinstance.
- Add a unit test that
- 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.