DartAdvanced 2 min read

Dart SDK migration: preview, apply and verify upgrades

Use the Dart 3.14 migration tool without confusing it with historical null-safety migration.

On this page

An SDK upgrade can require preparatory fixes before the package’s language version changes. Dart 3.14 provides a new dart migrate workflow for advancing compatible Dart 3 packages. This is not the historical pre-Dart-3 null-safety migration procedure.

Record a clean baseline

Commit your working source and save dart --version. Resolve dependencies, run analysis and execute the focused tests before upgrading. If Flutter controls the SDK, plan the matching Flutter upgrade rather than replacing only its Dart folder.

dart pub get
dart analyze
dart test
dart migrate --dry-run

Read the proposed SDK-constraint and source changes. Use dart migrate --help for the options supported by the installed revision. The migration tool guide documents staged preparation, version changes and optional cleanup.

Apply one reviewable change

Run dart migrate --apply only after reviewing the preview in your own package. Inspect the diff, resolve dependencies and rerun formatting, analysis and tests. dart fix --dry-run is a useful related inspection tool, but a general fix pass and an SDK migration have different scopes.

Generated files and public package contracts deserve separate review. An automatically updated import or syntax form can still affect a consumer that supports an older SDK. Do not raise a published package’s lower bound without considering its users.

Keep previews separate from stable support

Current documentation can mention an unreleased next version. Pin your supported baseline and label experiments explicitly. A new compiler accepting a construct does not mean an older package language version permits it. Prefer a small feature-based change over mechanically shortening every file.

Exercise

Create an upgrade report containing the previous revision, target revision, package lower bound, proposed fixes and test results. Explain why a successful formatter run is not evidence that a backend still returns the correct HTTP contract.

How this topic connects

Apply it next

Lesson progressMark complete after checking the example and exercise.

Find your next idea

Search lessons, code examples and projects.

Type a few words to start exploring.