Flutter Project Migration

 Migration to null safety in flutter.





Problem Statement: 


  • The newer versions of Flutter supports null safety but the older versions of Flutter does not have this type of support, and to run older applications makes it difficult to build or run the application  in it.

  • To overcome this problem we need to perform a migration of versions.

Solution of this problem:

  • Firstly we need to check the version of dart. It should be greater than or equal to 2.12.

  • To check the version of dart use the following command

    • dart --version

  • After that we need to check dependency status, use the following command to perform the dependency status check

    • dart pub outdated --mode=null-safety

  • Here’s an example of the output for a simple package. The green checkmarked version for each package supports null safety:

  • Before migrating the package’s code, update its dependencies to null-safe version:

    • Run dart pub upgrade --null-safety to upgrade to the latest versions supporting null safety. 

    • Note: This command changes your pubspec.yaml file.

    • Run dart pub get

  • Final process is to migrate the package code, Use the below command to migrate:

    • dart migrate

  • After executing the above command, a migration link will appear in the terminal. As shown in below image:





  • Click on the link.

  • After clicking on the link you will be redirected to the web page.









  • You will encounter this type of UI. As you can see suggestions will appear along with the file name which needs to apply to migration.

  • Final step click on the APPLY MIGRATION button.

Comments

Post a Comment

Popular posts from this blog

Url Launcher using Flutter

If and Else in Flutter