Skip to content

Instantly share code, notes, and snippets.

@belachkar
Created January 24, 2022 14:11
Show Gist options
  • Save belachkar/c77cdc8b853d4a69192b0e3db069ecb7 to your computer and use it in GitHub Desktop.
Save belachkar/c77cdc8b853d4a69192b0e3db069ecb7 to your computer and use it in GitHub Desktop.

Flutter project upgrade steps

To update the project to null safety follow these steps:

Side note: change the flutter version in pubsec.yaml, make new project and copy the following lines:

environment:
  sdk: ">=2.15.1 <3.0.0"

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^1.0.4

Then follow the steps:

  • Run flutter upgrade in the terminal to upgrade Flutter
  • Run dart migrate to run the dart migration tool.
  • Solve all errors which the migration tool shows.
  • Run flutter pub outdated --mode=null-safety to print all outdated packages.
  • Run flutter pub upgrade --null-safety to upgrade all packages automatically.
  • Check the code for errors and solve them (Very important).
  • Run dart migrate again and it should now be successful. Follow the link to checkout the proposed changes.
  • Press the Apply Migration button.
  • Check the code for errors again and fix them.

Your project should be updated now. Referenced from this felixlarsen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment