Dart null safety migration cheat sheet
A quick reference for your second migration
If you’ve already followed the migration guides in one of these places:
- Announcing Dart null safety beta blog post
- Migrating to null safety documentation
Then you know what to do. This article is a quick summary for migrating your second package or project so that you don’t have to sift through all the details in the documentation again.
Switch to the beta channel
flutter channel beta
flutter upgrade
Check dependency status
dart pub outdated --mode=null-safety
Replace any dependencies in pubspec.yaml with the null safety version.
dart pub upgrade
Note: I had an old package that didn’t use pedantic. This made Dart complain about null safety issues too early. You can add it to pubspec.yaml like so:
dev_dependencies:
pedantic: ^1.10.0-nullsafety.3
Migrate
dart migrate
(Skip that command if you are migrating manually.)
Get the current Dart version:
dart --version