Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should plugin developers manage the migration to Flutter 3? #103583

Closed
ryanheise opened this issue May 12, 2022 · 11 comments
Closed

How should plugin developers manage the migration to Flutter 3? #103583

ryanheise opened this issue May 12, 2022 · 11 comments
Labels
a: null-safety Support for the Dart's team new null safety feature framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. r: solved Issue is closed as solved

Comments

@ryanheise
Copy link

Flutter 3 introduces nullability changes to WidgetsBinding but plugins (including the first class plugins) have been using a version spec like this:

  sdk: ">=2.14.0 <3.0.0"
  flutter: ">=2.10.0"

The first issue is that I assume that Flutter 3 could in theory introduce breaking changes because it is a major version bump, yet the constraint >=2.10.0 doesn't guard against that.

But the second issue is that if a plugin migrates to Flutter 3 and uses the new nullability on WidgetsBinding, and sets a minimum Flutter version constraint to ">=3.0.0", then we are likely to have a similar situation to the Flutter 2 migration with many plugins lagging behind in the migration process blocking the adoption of Flutter 3.

What is the official advice on how to manage the Flutter 3 migration process?

The video_player plugin has a workaround in the form of:

T? _ambiguate<T>(T? value) => value;
...
_ambiguate(WidgetsBinding.instance)!

This technique could be helpful to include in the official migration advice.

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 12, 2022
@darshankawar
Copy link
Member

Thanks for the report. Keeping it open for further insights from the team.

@darshankawar darshankawar added p: framework a: null-safety Support for the Dart's team new null safety feature framework flutter/packages/flutter repository. See also f: labels. and removed in triage Presently being triaged by the triage team labels May 12, 2022
@goderbauer
Copy link
Member

@goderbauer goderbauer added P2 Important issues not at the top of the work list plugin and removed P2 Important issues not at the top of the work list labels May 12, 2022
@goderbauer
Copy link
Member

Related: #103561

@Hixie
Copy link
Contributor

Hixie commented May 12, 2022

in flutter/website#7128 i add the _ambiguate suggestion to the release notes

@stuartmorgan
Copy link
Contributor

stuartmorgan commented May 12, 2022

But the second issue is that if a plugin migrates to Flutter 3 and uses the new nullability on WidgetsBinding, and sets a minimum Flutter version constraint to ">=3.0.0", then we are likely to have a similar situation to the Flutter 2 migration with many plugins lagging behind in the migration process blocking the adoption of Flutter 3.

People updating Flutter constraints to 3.0.0 wouldn't create the kind of problem the NNBD transition did, because updating the minimum Flutter version isn't a breaking change. Someone can adopt Flutter 3 for their app with an arbitrary combination of plugins that require 3.0, plugins that support older versions with something like ambiguate, and plugins that haven't been updated at all (and thus have warnings).

The Flutter 2/NNBD transition was a very unusual case caused by needing to ripple breaking version changes, which must be explicitly adopted and which conflict with un-migrated dependency trees, across essentially the entire ecosystem.

@ryanheise
Copy link
Author

I think there is still an issue here. Because plugins do not include a maximum constraint on Flutter, that is implicitly saying that a plugin will continue to work on every future version of Flutter. This change to nullability in Flutter 3 fortunately only generates compiler warnings and not errors, but in theory, new Flutter versions could introduce API changes that also generate compiler errors. So why aren't plugins placing a maximum constraint on the Flutter version?

Reading the Flutter compatibility policy, there is also no indication that semantic versioning is being used to indicate breaking changes, which would make it very difficult to actually know what the correct maximum constraint should be.

If these constraints were all made explicit, the migration advice might suggest not only using _ambiguate, but also reflecting the corresponding Flutter versions that this supports.

@Hixie
Copy link
Contributor

Hixie commented May 13, 2022

So why aren't plugins placing a maximum constraint on the Flutter version?

Because as you say, we give:

no indication that semantic versioning is being used to indicate breaking changes, which would make it very difficult to actually know what the correct maximum constraint should be.

In fact, we don't use semantic versioning for Flutter at all, because every release has breaking changes, so it would be somewhat pointless.

There's really no way to know what the maximum version should be.

@christopherfujino
Copy link
Member

christopherfujino commented May 13, 2022

Related #95472 (TL;DR there is currently no way to constrain a maximum Flutter version, by design)

@stuartmorgan
Copy link
Contributor

See also #96282 which highlights some of the reasons semver wouldn't work well for Flutter.

(Also note that if we did use semver, and package authors did set constraints, the effect would be that every single Flutter package would stop working every time Flutter were updated, and they would all have to be updated by their authors every time. And running pretty much anything on master would be impossible. It would be a lot worse than the current situation.)

@goderbauer goderbauer added the P2 Important issues not at the top of the work list label May 18, 2022
@stuartmorgan
Copy link
Contributor

I'm going to close this; flutter/website#7128 documented the specific issue requested the issue was about (how libraries can handle this specific change in Flutter 3.0). And as discussed above, the secondary question of maximum Flutter versions is intentionally the way it is; any further discussion there would belong in #96282.

@darshankawar darshankawar added the r: solved Issue is closed as solved label Jul 18, 2022
@github-actions
Copy link

github-actions bot commented Aug 1, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2022
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: null-safety Support for the Dart's team new null safety feature framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

6 participants