I upgraded my Flutter SDK and now my project is broken. I need to basically revert back to a Flutter SDK which uses Dart 1.x.
I tried the following in the pubspec.ya
flutter version
is no longer available: Could not find a command named "version".
To choose version:
Delete old flutter folder; Download the archive and unzip to flutter folder.
OR
cd "$(dirname $(which flutter))"
then
git checkout .
(optional)
git pull origin
(optional)
git checkout v1.xxxxx
flutter doctor
p.s. Don't forget to restart your android studio
flutter version vX.X.X
, use flutter downgrade
instead.Warning: "flutter version" will leave the SDK in a detached HEAD state. If you are using the command to return to a previously installed SDK version consider using the "flutter downgrade" command instead.
So, you should use
flutter downgrade
Edit:
If there had been no previous versions installed, the above command would fail. So, if you have a specific version of Flutter that you’d like to switch to, you can use the flutter version command:
flutter version v1.17.0
You can find list of versions here
Flutter is versioned using git. Changing the Flutter version is as simple as changing git branch.
There are 2 different ways:
flutter channel <branch>
(example: flutter channel stable
)This command is used to change between branches – usually stable
/dev
/beta
/master
.
We can also put a specific commit id from git.
flutter version <version>
(example: flutter version v1.2.1
)This command will use a specific version number.
You can have the list of the available version numbers using flutter version
or here
After this, run any Flutter command (such as flutter doctor
), and Flutter will take care of downloading/compiling everything required to run this version.
In the Flutter install directory execute
git checkout v0.1.9
then run
flutter doctor
You can check which versions are available in the Flutter GitHub repository https://github.com/flutter/flutter
There is an open feature request to make this easier https://github.com/flutter/flutter/issues/14230
Run the following command to see a list of available versions.
flutter version
Then choose a version you want to switch to by running
flutter version v1.2.1
To undo and revert back to stable
flutter channel stable
flutter upgrade