The original

Migrating a project from a lower to a higher release is painful every time the technology changes to a new major release. Fortunately, Dart has a migration tool that can help you migrate the definitions in your project to the new syntax.

But even if you’re ready to switch to a newer version, you’ll have to wait for a set of plug-ins to be used in your project, and even in my case, I did help migrate some open source libraries to null-safety, which wasn’t enough to move my project to the next version.

The community is growing every day, and in most cases you will find alternative plug-ins that have not yet been migrated. If you are stuck with previous VERSIONS of Flutter, this article will help you simplify switching between projects.

Version management

The Flutter version has a related Dart SDK version that can be cached locally into the Flutter cache folder, so you should keep some constraints in mind.

As a developer, you have several options to switch between versions:

  • Enter using the command line script (CLI)
  • Flutter Version Manager CLI
  • Follower graphical user interface

manual

This option is not common for you when you have two or three items and switch between them.

The Flutter CLI has Git-controlled version management, so it is easy to switch even using git checkout < tag >. To see the list of versions you can check out, simply run git tag-l and press q to exit when you find the version you want.

Download the required version

You can visit the Flutter release page to download a snapshot of the desired version and replace the environment variable version to use the downloaded version.

Flutter. Dev/docs/develo…

Flutter CLI

You can try to downgrade it using a flutter downgrade

command, but you will have a problem switching from 2.x to 1.

GIT

Fortunately, the Flutter SDK uses GIT to manage versions, so you can have a single directory to switch between, rather than downloading every version and reducing space on hardware.

Assume that your SDK copy is located in ~/ FLUTTER then:

Finally, you should see the output of the flutter — version command:

When you need to switch back to the latest version, and vice versa:

If you have no problem with this step, you can store these scripts and automate the downgrade/upgrade process by calling *. Sh file on the command line.

FVM (Flutter Version Manager)

Previously, when I developed applications based on React and ReactNative, I used NPM (Node Package Manager) to manage dependencies in my project, and a similar tool in Flutter is pub. Sometimes I need to change the NPM version, but it has Node version restrictions, so I need to do the same steps, download several versions, change directories, etc. To avoid this routine, I used NVM (node version manager), and I’m about to be better off.

Fortunately, Flutter has an unofficial tool called FVM that does the same thing. It manages Flutter versions and stores them on your hardware.

fvm.app/

FVM can be used in two ways:

  • In addition to the main Flutter SDK, there is a piece of hardware
  • Serves as the primary source of the Flutter SDK

Simply follow the instructions to install fvm.app/docs/gettin… And configuration instructions for fvm.app/docs/gettin… To set up your environment correctly.

Another surprising option is FVM’s GUI, called the Sidekick, which makes global or local (project) Flutter SDK versioning more comfortable if you’re not a big fan of the CLI.