Skip to content

Conversation

@Gustl22
Copy link
Contributor

@Gustl22 Gustl22 commented Oct 22, 2023

These changes allow to override existing native endorsed (federated & inline) plugins with e.g. non-endorsed plugin implementations via direct dependencies as described in the section Platform implementation selection in the design doc.

# pubspec.yaml
name: example
dependencies:
  my_plugin: ^0.0.1
  my_plugin_android_alternative: ^0.0.1

Closes #80374, closes #59657

Related: Override Dart plugins (#87991, #79669)

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 22, 2023
@Gustl22

This comment was marked as outdated.

@zr6328

This comment was marked as off-topic.

@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from b1121c3 to b8a1c9b Compare December 21, 2023 18:25
@stuartmorgan-g
Copy link
Contributor

It's hard to see what's changing here since it's mixed with some large-change refactors (most notably extracting _getPossiblePluginResolutions); pulling any purely code refactor into a simple prequel PR that doesn't also change logic would be useful in getting feedback here.

@Gustl22
Copy link
Contributor Author

Gustl22 commented Jan 9, 2024

Thanks, yes that was also my intention, I will have time in the coming week to work on it :)

auto-submit bot pushed a commit that referenced this pull request Jan 22, 2024
…141780)

Part of #137040 and #80374

- Rename _filterPluginsByPlatform to _createPluginMapOfPlatform
- Move method in chronological order
- Cleanup platform strings
auto-submit bot pushed a commit that referenced this pull request Feb 26, 2024
…42035)

Part of #137040 and #80374

- Differentiate pubspec and resolution errors
- Rename platform to platformKey
- Add TODO for rework logic of flag [throwOnPluginPubspecError]
- Swap for loop: handle by platform and then by plugin
auto-submit bot pushed a commit that referenced this pull request Mar 7, 2024
…on (#144214)

Part of #137040 and #80374

The flag `throwOnPluginPubspecError` never actually was enabled during production in #79669, but only in some dart plugin tests. And in the tests the case of the error when enabling the flag was not explicitly tested. The only thing tested was, that it is not thrown when disabled.

As explained [here](#142035 (comment)) the only case, where this error could be thrown is, when a dart implementation and a native inline implementation are provided simultaneously. But throwing an exception there is a wrong behavior, as both can coexist in a plugin package, thus in the pubspec file.

Disabling the flag means, that the error is not thrown and not shown to the user. This is the case in production (contrary to the dart plugin tests), which acts like these plugin cases of implementations are just skipped. And this is what actually should be done.

In conclusion, I think the case of coexisting dart and native implementation in pubspec was just overlooked and therefore this error validation was introduced, which is not necessary or even valid.

For more discussion, see: https://discord.com/channels/608014603317936148/608022056616853515/1200194937791205436

  - This is tricky: I already added a test in #142035, which finally complies with the other tests, by removing the flag. So I think it falls in the category of "remove dead code".
  - Theoretically this is a breaking change, as removing / altering some tests. But the flag actually was never valid or used, so IDK. But this may not does fall in the category of "contributed tests".
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from 819638d to 52c9c23 Compare March 8, 2024 09:48
auto-submit bot pushed a commit that referenced this pull request Apr 5, 2024
Part of #137040 and #80374

`possibleResolutions` and `possibleResolutions` used a key containing the platform and the plugin name via `getResolutionKey`. The global list is not necessary and also confusing. It can be avoided by handling the resolution of plugins per platform. This helps to have a more self-contained plugin resolution. This also is necessary to reuse the plugin resolution logic (per platform) for #137040.
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from 39af475 to c4666d9 Compare April 5, 2024 06:58
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
Part of flutter#137040 and flutter#80374

`possibleResolutions` and `possibleResolutions` used a key containing the platform and the plugin name via `getResolutionKey`. The global list is not necessary and also confusing. It can be avoided by handling the resolution of plugins per platform. This helps to have a more self-contained plugin resolution. This also is necessary to reuse the plugin resolution logic (per platform) for flutter#137040.
auto-submit bot pushed a commit that referenced this pull request May 7, 2024
…lution (#145258)

Part of #137040 and #80374

- Extracted getting plugin implementation candidates and the default implementation to its own method
- Extracted resolving the plugin implementation to its own method
- Simplify candidate selection algorithm
- Support overriding inline dart implementation for an app-facing plugin
- Throw error, if a federated plugin implements an app-facing plugin, but also references a default implementation
- Throw error, if a plugin provides an inline implementation, but also references a default implementation
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch 3 times, most recently from 71e0f47 to 738cfcb Compare May 8, 2024 21:14
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from f45fac5 to ad6dfb0 Compare May 13, 2024 12:48
@auto-submit auto-submit bot merged commit d55a5f9 into flutter:master Jul 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 11, 2024
@Gustl22 Gustl22 deleted the 80374-override-native-platform branch July 11, 2024 22:34
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
ditman added a commit to ditman/flutter-packages that referenced this pull request Jul 12, 2024
Roll Flutter from 5103d75 to 58068d8 (42 revisions)

flutter/flutter@5103d75...58068d8

2024-07-12 [email protected] Reland: Move all Linux Moto G4 tests to mokey in staging (flutter/flutter#151654)
2024-07-12 [email protected] Update obsolete comment in InputDecorator test (flutter/flutter#151651)
2024-07-12 [email protected] Fix `TabBar` tab indicator stretch effect (flutter/flutter#150868)
2024-07-12 [email protected] Remove workaround for a bug in dart2wasm (flutter/flutter#151603)
2024-07-12 [email protected] [native_assets] Stop running link hooks in JIT mode (flutter/flutter#151534)
2024-07-12 [email protected] Roll `Switch.adaptive` changes into `CupertinoSwitch` (flutter/flutter#149465)
2024-07-11 [email protected] Unmark java11 tests as bringup:true (flutter/flutter#151612)
2024-07-11 [email protected] Add link to design document archive (flutter/flutter#151489)
2024-07-11 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Move all Linux Moto G4 tests to mokey in staging (#151608)" (flutter/flutter#151620)
2024-07-11 [email protected] Move all Linux Moto G4 tests to mokey in staging (flutter/flutter#151608)
2024-07-11 [email protected] docimports for API samples (flutter/flutter#151606)
2024-07-11 [email protected] docimports for flutter_goldens, flutter_localizations, flutter_web_plugins, fuchsia_remote_debug_protocol, integration_test (flutter/flutter#151271)
2024-07-11 [email protected] Re-enable debug canvaskit e2e tests. (flutter/flutter#151565)
2024-07-11 [email protected] Fix: Submenu anchor misaligned with child panel in web (Resolved #151081) (flutter/flutter#151294)
2024-07-11 [email protected] Replaced {@tool snippet} with {@tool dartpad} in CupertinoTabController (flutter/flutter#151272)
2024-07-11 [email protected] feat: Support overriding native endorsed plugins (flutter/flutter#137040)
2024-07-11 [email protected] expose keyboardType in DropdownMenu #150894 (flutter/flutter#150896)
2024-07-11 [email protected] docimports for flutter_driver (flutter/flutter#151267)
2024-07-11 [email protected] Add `TimeOfDay` comparison methods (flutter/flutter#151233)
2024-07-11 [email protected] Roll Flutter Engine from 6534fbf3c2c1 to 36dccf7bb25c (2 revisions) (flutter/flutter#151577)
2024-07-11 [email protected] Roll Flutter Engine from 1c23c8f64076 to 6534fbf3c2c1 (3 revisions) (flutter/flutter#151572)
2024-07-11 [email protected] Use correct locale for `CupertinoDatePicker` weekday (flutter/flutter#151494)
2024-07-10 [email protected] doc imports for enum values (flutter/flutter#151548)
2024-07-10 [email protected] Reland "Upgrade template Gradle, App AGP, Module AGP, and Kotlin versions, and tests"... but no longer upgrade module AGP version (flutter/flutter#151433)
2024-07-10 [email protected] Roll Packages from 14341d1 to ea35fc6 (16 revisions) (flutter/flutter#151556)
2024-07-10 [email protected] [CupertinoActionSheet] Fix padding and font size of buttons (flutter/flutter#151199)
2024-07-10 [email protected] Roll Flutter Engine from db2b45bea2c0 to 1c23c8f64076 (2 revisions) (flutter/flutter#151550)
2024-07-10 [email protected] Add docImports for flutter_test references (flutter/flutter#151175)
2024-07-10 [email protected] Mention not @-mentioning people in commit messages in tree hygiene (flutter/flutter#151487)
2024-07-10 [email protected] Roll Flutter Engine from 371db85f33d7 to db2b45bea2c0 (8 revisions) (flutter/flutter#151522)
2024-07-10 [email protected] fix heading level absorption, diagnostics; add tests and an a11y use-case (flutter/flutter#151421)
2024-07-10 [email protected] Roll Flutter Engine from 9d943eb2b37a to 371db85f33d7 (3 revisions) (flutter/flutter#151505)
2024-07-10 [email protected] Roll Flutter Engine from d3269d5855a7 to 9d943eb2b37a (5 revisions) (flutter/flutter#151495)
2024-07-09 [email protected] Update doc of `SemanticsProperties.identifier` (flutter/flutter#149915)
2024-07-09 [email protected] Clean up leaky test. (flutter/flutter#151131)
2024-07-09 [email protected] Roll pub packages (flutter/flutter#151492)
2024-07-09 [email protected] testAdd tests for stepper.controls_builder.0.dart (flutter/flutter#150669)
2024-07-09 [email protected] Add Semantics Property `linkUrl` (flutter/flutter#150639)
2024-07-09 [email protected] Roll Flutter Engine from 4a2ac0e51a8f to d3269d5855a7 (1 revision) (flutter/flutter#151488)
2024-07-09 [email protected] Link engine docs on AS setup in flutter/flutter docs on engine contributor setup (flutter/flutter#151481)
2024-07-09 [email protected] Roll Flutter Engine from 69075e7e87d4 to 4a2ac0e51a8f (21 revisions) (flutter/flutter#151482)
2024-07-09 [email protected] Fix Material 3 `Dialog` default background color (flutter/flutter#151400)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
Gustl22 added a commit to Gustl22/flutter-website that referenced this pull request Jul 14, 2024
auto-submit bot pushed a commit that referenced this pull request Aug 22, 2024
Clarify that a referenced default package must also be a plugin package (one, which provides a pluginClass or a dartPluginClass).

Fixes #152037
More precisely #152037 (comment).
Introduced in #137040
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…52134)

Clarify that a referenced default package must also be a plugin package (one, which provides a pluginClass or a dartPluginClass).

Fixes flutter#152037
More precisely flutter#152037 (comment).
Introduced in flutter#137040
sfshaza2 pushed a commit to flutter/website that referenced this pull request Dec 12, 2024
DRAFT: It should may land only after the next major release, when
functionality is available in stable.

_Description of what this PR is changing or adding, and why:_

It is now possible to override native or Dart endorsed plugin
implementations. This should be reflected in the docs.

_Issues fixed by this PR (if any):_

flutter/flutter#80374, flutter/flutter#59657, flutter/flutter#137040
See also:
flutter/flutter#80374 (comment)

_PRs or commits this PR depends on (if any):_


flutter/flutter@d55a5f9

## Presubmit checklist

- [x] This PR is marked as draft with an explanation if not meant to
land until a future stable release.
- [x] This PR doesn’t contain automatically generated corrections
(Grammarly or similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.
@emakar
Copy link
Contributor

emakar commented Mar 14, 2025

Should I expect default implementation to become absent once overridden?
I've added

  camera: 0.11.1
  camera_android: 0.10.10+1

but now pubspec.lock contains both camera_android and camera_android_camerax
I'm using flutter 3.29

@Gustl22
Copy link
Contributor Author

Gustl22 commented Mar 15, 2025

As far as I remember, this is expected, as Flutter needs both packagages in order to check which one has implementations which can be overriden, when exclusively stating it as direct dependency.
Can you have a look if it' still written in .flutter-plugins-dependencies as dependency of camera_android?

@emakar
Copy link
Contributor

emakar commented Mar 15, 2025

I have both camera_android and camera_android_camerax among dependencyGraph in .flutter-plugins-dependencies

I actually don't understand why any changes were needed since we can just omit mention of "impl" plugin in dependencies of app facing plugin - then app can either choose impl 1, or impl 2, etc

I also don't understand why app facing plugin needs to define default plugin for endorsement whereas it could just depend on it effectively making it endorsed? (currently I see a common practice to both define a default impl and also depend on it)
Maybe I should read through documentation and flutter_plugins.dart once more :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Federated Plugins] Provide a way to override a default/endorsed platform implementation Support overriding the implementation of a federated plugin

6 participants