-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Hello!
There appears to be an unfortunate side-effect to treating constraints such as sdk: >=2.x.z <3.0.0 as sdk: >=2.x.z <4.0.0.
This effectively marks versions non-compatible with the breaking changes in Dart 3.0 to be compatible with it anyway.
As an example, consider a package A that:
- in version 1.0.0 is using
NullThrownError, which was removed in Dart 3 - has for SDK constraint
sdk: >=2.x.z <3.0.0, which matches with what the package supports - has a more recent version 1.1.0 available that is Dart 3 compatible (as in, its sdk constraint explicitly allows Dart 3)
Then, a second package B depends on package A, but with looser version constraints.
- package B is compatible with both Dart 2 and Dart 3
- package B is also compatible with all versions of package A
In that situation, B has effectively for pubspec:
name: b
environment:
sdk: ">=2.12.0 <4.0.0"
dependencies:
a: ^1.0.0With those constraints, there is now an issue when running pub downgrade on an app depending on B when using Dart 3.
Instead of resolving the version of A with v1.1.0 which is Dart 3 compatible, the command will resolve with v1.0.0 which is not Dart 3 compatible.
As such, the application will fail to start.
This is confusing because, at all points, the package authors and application authors used the correct version constraints.
- The author of
Acorrectly said Dart 3 wasn't supported in their version 1.0.0 and correctly published a newer Dart 3 compatible version - The author of
Bcorrectly supports Dart 2 and 3 at the same time - The app author which depends on
Bdoesn't useA, so they shouldn't have to care about the minimumAversion