How to create Multiple Flutter Aliases to use in command prompt in Windows PC separately

Viewed 825

I have 2 versions of flutter 1 is latest another is previous, I want to create a 'flutterl' alias for cmd in windows for latest one and 'flutter' for previous one. how to create it ?

3 Answers

It is very simple to do just follow these steps:

In my case i will be using 2 different commands like flutter for current flutter version and flutterl for latest flutter version.

To create a new alias in windows you should create a new folder. here i have created Aliases, you can create this folder in C directory or wherever you want.

enter image description here

In this folder create a new file flutterl.bat

enter image description here

And right click and edit this file add the following code

@echo off
C:\src\flutter_latest\bin\flutter %*

Here C:\src\flutter_latest is the location, which contain's flutter latest version.

Then goto Environment variables and in the path add this files location. To do this you can follow these steps

  1. Right click on this pc, and click on properties
  2. Click on Advanced Settings
  3. Then click on Environment Variables
  4. Edit Path
  5. Click on new and paste the Location of Aliases folder, that you've created

Same Steps with visuals

  1. Right click on this pc, and click on properties

enter image description here

  1. Click on Advanced Settings

enter image description here

  1. Then click on Environment Variables

enter image description here

  1. Edit Path

enter image description here

  1. Click on new and paste the Location of Aliases folder, that you've created

enter image description here

Now you are good to go. Both flutter and flutterl will be working fine to test then run

flutter doctor
flutterl doctor

If you want to manage the flutter versions for your project only then you can use fvm package, it is a simple cli to manage Flutter SDK versions. Flutter Version Management

You will have to use Flutter Version Manager - FVM https://github.com/leoafarias/fvm

Flutter Version Management: A simple CLI & GUI to manage Flutter SDK versions.

FVM helps with the need for a consistent app builds by allowing to reference Flutter SDK version used on a per-project basis. It also allows you to have multiple Flutter versions installed to quickly validate and test upcoming Flutter releases with your apps, without waiting for Flutter installation every time.

Create a hard link to one

MKLINK /H "C:\Path\for\link\flutterl.exe"  "c:\path\to\latest\version\flutter.exe"
Related