How to downgrade Flutter SDK (Dart 1.x)

Flutter

Flutter Problem Overview


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.yaml,

environment:
  sdk: ">=1.19.0 <2.0.0"
  flutter: "^0.1.2"

dependencies:
  flutter:
    sdk: flutter

but now the project just simply doesn't build.

Running "flutter packages get" in binformed...
Package binformed requires Flutter SDK version ^0.1.2 but the current SDK is 0.2.5-pre.38.
pub get failed (1)

Do i need to uninstall the SDK and reinstall it?

Flutter Solutions


Solution 1 - Flutter

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 downgrade <version> (example: flutter downgrade v1.2.1)

This command will use a specific version number. You can have the list of the available version numbers using flutter downgrade 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.

Solution 2 - Flutter

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

Solution 3 - Flutter

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

enter image description here

There is an open feature request to make this easier https://github.com/flutter/flutter/issues/14230

Solution 4 - Flutter

Don't use 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 downgrade v1.17.0

You can find list of versions here

Solution 5 - Flutter

To downgrade there are many deprecated commands.

The two that actually work, and I've tested them, are:

flutter downgrade v[flutter build version]

For instance:

flutter downgrade v1.22.6

And the other one: go to your flutter sdk folder, that is your folder named "flutter" and inside it open a new terminal. Then type:

git checkout [flutter build version]

For instance:

git checkout 1.22.3

Then do flutter doctor and you'll confirm you switched correctly.

You can check the versions on: https://flutter.dev/docs/development/tools/sdk/releases?tab=macos

And for details at: https://flutter.dev/docs/release/breaking-changes


If you happen to want to switch channel, just do:

flutter channel [channel]

For instance (choose one of master, stable, dev, beta):

flutter channel stable

And if you want to upgrade again:

flutter upgrade

Solution 6 - Flutter

Inorder for a proper downgrade to any version.

  1. Change to Dev mode

    flutter channel dev

  2. flutter downgrade v(type your version number) eg below.

    flutter downgrade v2.0.6

This worked for me !

Solution 7 - Flutter

Go to the terminal and type the specific version number, for eg -

flutter downgrade v1.22.3

Then just press enter. After fetching the files from the internet, it will ask,

Downgrade flutter to version 1.22.5
? [y|n]:

Type y and it will downgrade to the specific version.

Restart the IDE for the settings to take place.

enter image description here

Solution 8 - Flutter

To solve these errors:

$ flutter version
Could not find a command named "version".
$ flutter downgrade v1.22.6
There is no previously recorded version for channel "stable".

Delete old flutter folder

Download the archive and unzip instead of deleted flutter folder

OR

cd "$(dirname $(which flutter))" then

git checkout . (optional)

git pull origin (optional)

git checkout v1.22.6

flutter doctor

p.s. Don't forget to restart your android studio

Solution 9 - Flutter

At the moment, the easiest way to manage flutter versions is through fvm.

  1. Install fvm
brew tap leoafarias/fvm
brew install fvm
  1. Install your version
fvm install x.x.x
  1. Install your version globally (if desired)
fvm global x.x.x

Here's a link to the app guide

https://fvm.app/docs/getting_started/installation

Solution 10 - Flutter

Just use flutter downgrade v2.8.0 then flutter ask for confirmation

Downgrade flutter to version 1.22.5
? [y|n]:

Type y for Yes to confirm changes

Solution 11 - Flutter

  1. Download Flutter SDK release: flutter_windows_1.17.0-stable: https://flutter.dev/docs/development/tools/sdk/releases
  2. Replace the existing Flutter folder to this version
  3. Make sure that environment variables and Flutter + Dart Settings on your IDE are still tied to this folder/path

Solution 12 - Flutter

Just flutter downgrade is enough, it will downgrade to previous stable version.

Solution 13 - Flutter

I find it a little tough to switch (upgrade/downgrade) to a specific Flutter version from the command line. Some of the answers here are outdated.

I prefer to download the SDKs for different versions from here manually.

  • Let's say I download 2.0.1, 2.0.5 and 2.0.6.
  • 2.0.1 is the current Flutter SDK version for me.

To switch to 2.0.5, delete the current Flutter SDK (the one with the blue icon) and unzip flutter_macos_2.0.5-stable.zip. Then run flutter clean followed by flutter doctor to confirm that everything worked correctly.

This has the benefit of not having to change any paths or having to re-download the entire SDK every time you want to switch.

On macOS, if you get system warnings for not being able to run dart or gentool, then press Allow anyway under System Preferences > Security & Privacy

enter image description here

Solution 14 - Flutter

This solutions works in 2021

Go to your flutter SDK folder, which is your folder named "flutter" and inside it open a new terminal. Then type:

git checkout (your flutter version) then, run flutter doctor After this check your version.

enter image description here

Solution 15 - Flutter

if you are using brew (macos)

you can create rb file and use brew to install or downgrade flutter

create file with name flutter.rb

cask "flutter" do
  version "2.2.0"

  url "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_#{version}-st$
      verified: "storage.googleapis.com/flutter_infra_release/"
  name "Flutter SDK"
  desc "UI toolkit for building applications for mobile, web and desktop"
  homepage "https://flutter.dev/"

  livecheck do
    url "https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json"
    regex(%r{/flutter[._-]macos[._-]v?(\d+(?:\.\d+)+)[._-]stable\.zip}i)
  end

  auto_updates true

  binary "flutter/bin/dart"
  binary "flutter/bin/flutter"
end

then use brew install ./flutter.rb to install flutter or downgrade flutter version

Solution 16 - Flutter

The simplest way to change your flutter version is to:

  1. Navigate to this link and download the flutter version you want.
  2. Extract the files and replace your older flutter directory with them.
  3. If you were using flutter already then no need to redefine the PATH, else, make sure that environment variables are still tied to this folder/path.
  4. Run flutter --version or flutter doctor to check that everything went ok.

Solution 17 - Flutter

To downgrade your flutter version:

Run flutter downgrade v2.5.3 or whatever flutter version you want from here.


If it resulted in any error like

> There is no previously recorded version for channel "stable".

or that there is no previous version,

then, make sure to switch to the correct branch {stable, master, dev, beta} using the following command:

flutter channel master 

Finally, Run flutter doctor to check that everthing went well.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStephaneView Question on Stackoverflow
Solution 1 - FlutterRémi RousseletView Answer on Stackoverflow
Solution 2 - FlutterGrahamView Answer on Stackoverflow
Solution 3 - FlutterGünter ZöchbauerView Answer on Stackoverflow
Solution 4 - FlutterCopsOnRoadView Answer on Stackoverflow
Solution 5 - FlutterIván YoedView Answer on Stackoverflow
Solution 6 - FlutterCraftspot DesignsView Answer on Stackoverflow
Solution 7 - FlutterMaruf HassanView Answer on Stackoverflow
Solution 8 - FlutterNutsView Answer on Stackoverflow
Solution 9 - FluttermskolnickView Answer on Stackoverflow
Solution 10 - FlutterVishal_VEView Answer on Stackoverflow
Solution 11 - FlutterClarissaView Answer on Stackoverflow
Solution 12 - FlutterSumedhView Answer on Stackoverflow
Solution 13 - FlutterRohan TanejaView Answer on Stackoverflow
Solution 14 - FlutterLaraib. SheikhView Answer on Stackoverflow
Solution 15 - FlutterHussein Abd ElazizView Answer on Stackoverflow
Solution 16 - FlutterMostafa WaelView Answer on Stackoverflow
Solution 17 - FlutterMostafa WaelView Answer on Stackoverflow