If you publish Dart packages or like to use early releases of the Dart SDK, the next few months are going to be interesting, as apps and packages adapt to the changes required by Dart 2.0. To make the process smoother, the pub tool that’s in Dart 2.0 pre-releases allows developers to download (and attempt to use) packages that don’t explicitly support Dart 2.0.
- Use a stable Dart SDK if you need reliability.
- Use a pre-release Dart 2.0 SDK if you’d like to test published packages with Dart 2.0. Report any issues you find to the package maintainer.
- If you publish packages, be careful about SDK constraints, and expect feedback from developers trying your packages with Dart 2.0.
The Dart 2.0 update page has all the details, but here’s an overview of what to expect, based on your development environment and the kind of code you write.
If you use Flutter: In the short term, your Flutter code isn’t affected. When Flutter updates its Dart SDK to a Dart 2.0 pre-release, the Flutter team will tell you how to manage your dependencies.
If you use a stable Dart SDK: When running
pub upgrade, you might notice that you aren’t getting the latest releases of some packages. This might happen because the packages have versions that require a Dart 2.0 feature. Consider checking the release notes of critical packages to see whether the packages have important fixes or new features.
If you use a dev channel Dart SDK: When running
pub upgrade, or other pub commands from a 2.0 pre-release, you might get packages that haven’t been verified to work with 2.0. If you find a package that has 2.0 issues, please report those issues immediately to the package maintainer, and let the Dart community know about any workarounds you find.
If you publish packages: Don’t change your already-published packages just to add SDK constraints to the pubspec. If you do need to change a package, try to make your changes backward compatible with Dart 1.x. Before publishing a package, make sure that the pubspec has correct lower and upper SDK constraints. Use <2.0.0 as the upper constraint, for now. Examples:
# Works in 1.20.1+; might work in 2.0.0-dev: sdk: '>=1.20.1 <2.0.0' # Backward incompatible change requires at least 2.0.0-dev.1.2: sdk: '>=2.0.0-dev.1.2 <2.0.0'
For more information about how to adapt your code for Dart 2.0, see the Dart 2.0 update page.