flutterdartdebuggingupgrade

The good way to restore an abandoned 3 years old Flutter project?


I am a beginner in Flutter and Dart.

Recently, I was introduced in a new project : restore a 3 years old flutter project. No commits have been made for 3 years All dependancies are in an old obsolete version (no one has been null safety) - or deprecated -, Flutter and the Dart SDK are update since 3 years.

My problem : How I can "upgrade" this project correctly ? Is there a good way/method to "migrate" an old project to the most recent update of the Dart SDK/Flutter and his dependancies ?

First, I upgrade, replace and remove all the dependancies that needed (dependancies without null safety) and launch the command flutter pub upgrade --major-versions. The result of this was 1000 errors in the code due to changing, deleting and updating dependencies.

During my research, I found the command dart migrate, but it was removed in Dart 3.

I don't know if I take the good way to restore this Flutter project. I want to know if there is a better method to do that (obviously, I launch the command dart fix --apply, it has fixed some minor errors).

Thanks in advance for answers !


Solution

  • For the migration to null safety, I recommend you use the interactive migration tool offered through the dart migrate command.

    https://dart.dev/null-safety/migration-guide#migration-tool

    And in general, I recommend you to read the whole page there, there's really useful information and hints on how to do exactly what you are trying to do :)

    To add to that, as mentioned on that page you should use Dart 2.19.6 to run the migration tool, and once migrated upgrade to the next version. This will likely also mean upgrading to 'intermediate' versions of your dependencies that still support this Dart version.

    As the other commenters said already, it'll be quite tedious, but hopefully the tool can help a bit