[Flutter] How to reduce the version of Dart/Flutter SDK and roll back to the specified version

Because no-sound-null-safety is no longer supported after dart3.0; but some projects cannot continue to use running projects before switching to dart3.0

method 1:

pass

$ flutter downgrade

command to downgrade flutter to the last active version of the current channel;

If there is no old version, it will prompt

flutter downgrade
There is no previously recorded version for channel “stable”.

In this case, you can roll back to the specified version by the following method

Method Two:

Switch to the specified version through git

1. First find the flutter sdk directory

Users of macOS and Linux can use the which command on the command line to view the path of the flutter SDK:

$ which flutter

Windows users can use the where command on the command line to view the path of the flutter SDK:

$ where flutter

If the directory is as follows

insert image description here

Enter the sdk directory through the cd command

$  cd /Users/android/Documents/Flutter/flutter/

2. View the historical version of flutter

able to pass

$ git tag

Also checked the released version on github

3. Switch to the designated branch
and use

git checkout version

command or

git reset --hard version

fallback version

The main difference between the two commands is:

  • git checkout version: Equivalent to flutter version (deprecated), it will force the branch of git to switch to the branch where the specified version is located.

  • it reset --hard version: Only the version number on the current branch can be rolled back. If the specified version number is not on the current branch, the rollback will fail.

The command is as follows:

git checkout 3.7.8    //推荐方法
或
git reset --hard 3.7.8

After the switch is complete,
you can view the version through flutter --version

$ flutter --version

insert image description here

This will allow you to continue compiling the project, but we'd better update the project to empty safe as soon as possible!

Guess you like

Origin blog.csdn.net/mingtiannihao0522/article/details/131098549