Migrating your packages to Dart 2

Skip to first unread message

Michael Thomsen

Jul 20, 2018, 6:31:39 PM7/20/18
to Dart Announcements

We expect the Dart 2 release to graduate to stable in the immediate future. Thus, it’s critical that you migrate your code — especially any packages you have published — to be Dart 2 compatible now!

There are three main aspects to this:

  • Make sure your code passes Dart 2 analysis (details). We recommend you also pay attention to hints — for example, to prepare for deprecations.

  • Run tests to make sure your code passes Dart 2 runtime checks (details).

  • Update the upper bound of the SDK constraint of your packages to <3.0.0 (details).

We strongly encourage all package authors to do this work as soon as possible. To support this work, we’ve made some enhancements to the Pub site to better show potential issues. See our Medium post for full details.

Kevin Moore

Jul 25, 2018, 4:50:28 PM7/25/18
to Dart Announcements
If you'd like to verify that your package and all of your dependencies are ready for Dart 2, you can set an environment variable to force the pub client to run as if the current SDK is the stable release.

On Linux and Mac:

$> _PUB_TEST_SDK_VERSION=2.0.0 pub upgrade

On Windows, you can use the setx command then run pub upgrade.

If the command succeeds, you can be confident SDK Constraints won't cause problems when Dart 2 stable is released.

If the command fails, look at the output to determine which packages need to be fixed.

$> _PUB_TEST_SDK_VERSION=2.0.0 pub upgrade
Resolving dependencies... (5.2s)
The current Dart SDK version is 2.0.0.

Because repo_manager depends on gviz >=0.1.0 which requires SDK version >=1.20.1 <2.0.0, version solving failed.

In this case, we should file an issue (or, better yet, a pull request) on the gviz package to be updated.

You can also use _PUB_TEST_SDK_VERSION to control the behavior of the pub client after Dart 2 is released if you some of your dependencies have not yet been updated.

Note: _PUB_TEST_SDK_VERSION was implemented to support testing the pub client. It may change or be removed at any point. Avoid using it in production environments.
Reply all
Reply to author
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages