Update your Flutter project to Flutter 2.0

Upgrade and Migrate Flutter project to 2.0

Follow these steps:

I want to update my current project to Flutter 2.0 to make use of the new dart sound null-safety
— Problem InShort
  1. Run flutter upgrade in the terminal to upgrade Flutter
  2. Run dart migrate to run the dart migration tool
  3. Solve all errors which the migration tool shows
  4. Run flutter pub outdated --mode=null-safety to print all outdated packages
Screenshot 2021-03-09 at 21.18.05.png

You can see if the packages you depend upon support null-safety.

  1. Run flutter pub upgrade --null-safety to upgrade all packages automatically
  2. Check the code for errors and solve them
  3. Run dart migrate again and it should now be successfull. Follow the link to checkout the proposed changes
  4. Press the "Apply Migration" button
  5. Check the code for errors again and fix them

Congratulations, when finished you should now be able to run the app with sound null-safety.

Run flutter run in the command line and the application should run with the command line displaying:

Screenshot 2021-03-09 at 22.14.28.png