Why is video_player
's android and iOS code not federated?
Is this just an historical artefact or do the ios and android packages still need to be part of the main plugin?
It appears to either be:
- a convenience:
flutter create
will create a package easily with android/ios boilerplate
- historical artefact: They might have created the package before federated plugins were released. (This is why people have requested the flutter create plugin template to generated a federated plugin automatically).
Correct package structure
If they can be separated out what is the correct package(s) structure?
They can be separated out.
For pigeon specifically, you can put the Dart generated code (from Pigeon) in your Platform specific interface, and your Native platform generated code (from Pigeon) in your platform specific package.
In your platform specific package, you should declare it to be a federated plugin (see docs and url_launcher), where url_launcher
is the app facing package in that example:
flutter:
plugin:
implements: url_launcher
platforms:
macos:
pluginClass: UrlLauncherPlugin
fileName: url_launcher_macos.dart
Example package
If you take a look at url_launcher, all platforms have federated plugin packages.

Why federate
The advantage of creating a separate platform specific package is that a user can override the default implementation. For video_player, a user cannot override Android or iOS implementation because it is in the app-facing package.
More reading
After writing the above, I found this GitHub issue which goes over a lot of our concerns: https://github.com/woodemi/quick_flutter.brick/issues/22