Dart 2.12 release — Null Safety

Take a look at Dart null safety and learn how to migrate your Flutter project to it.

Table of contents

Overview: Sound null safety

Migrating your Flutter project to null safety

Switch to a Dart 2.12 release

flutter channel beta
flutter upgrade

Change SDK constrains over 2.12

environment:
sdk: ">=2.12.0 <3.0.0"
void main() {
var hello = 'Hello Flutter';
hello = null; // Cannot be assigned to null.
print(hello);
runApp(MyApp());
}

Check dependency status

flutter pub outdated --mode=null-safety
flutter pub get
flutter pub outdated --mode=null-safety
flutter pub upgrade --null-safety

Using the migration tool

dart migrate
View the migration suggestions by visiting:

http://127.0.0.1:60278/Users/you/project/mypkg.console-simple?authToken=Xfz0jvpyeMI%3D

An Android/Flutter engineer at Line Corporation.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store