Flutter 多版本管理
Flutter 刘宇帅 3年前 阅读量: 1950
安装 fvm
dart pub global activate fvm
拷贝以下内容到你的 .bashrc|.zshrc ... 文件中
export PATH="$PATH":"$HOME/.pub-cache/bin"
source ~/.zshrc
查看 fvm 命令
(base) ➜ ~ fvm -h
Flutter Version Management: A cli to manage Flutter SDK versions.
Usage: fvm <command> [arguments]
Global options:
-h, --help Print this usage information.
--verbose Print verbose output.
--version current version
Available commands:
config Set configuration for FVM
dart Proxies Dart Commands
doctor Shows information about environment, and project configuration.
flavor Switches between different project flavors
flutter Proxies Flutter Commands
global Sets Flutter SDK Version as a global
install Installs Flutter SDK Version
list Lists installed Flutter SDK Versions
releases View all Flutter SDK releases available for install.
remove Removes Flutter SDK Version
spawn Spawns a command on a Flutter version
use Sets Flutter SDK Version you would like to use in a project
Run "fvm help <command>" for more information about a command.
安装最新稳定版本 2.2.0
(base) ➜ ~ fvm install 2.2.0
Flutter "2.2.0" is not installed.
Installing version: 2.2.0...
Cloning into '/Users/liushuai/fvm/versions/2.2.0'...
remote: Enumerating objects: 303573, done.
remote: Total 303573 (delta 0), reused 0 (delta 0), pack-reused 303573
Receiving objects: 100% (303573/303573), 140.02 MiB | 1.85 MiB/s, done.
Resolving deltas: 100% (234946/234946), done.
Updating files: 100% (5159/5159), done.
Downloading Dart SDK from Flutter engine a9d88a4d182bdae23e3a4989abfb7ea25954aad1...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 200M 100 200M 0 0 1737k 0 0:01:57 0:01:57 --:--:-- 1157k
Building flutter tool...
Connection closed before full header was received
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
Connection closed before full header was received
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)
Flutter 2.2.0 • channel unknown • unknown source
Framework • revision b22742018b (8 days ago) • 2021-05-14 19:12:57 -0700
Engine • revision a9d88a4d18
Tools • Dart 2.13.0
设置默认版本
(base) ➜ ~ fvm global 2.2.0
Flutter "2.2.0" has been set as global
However your "flutter" path current points to:
/Users/liushuai/bin/flutter/bin
to use global Flutter SDK through FVM you should change it to:
/Users/liushuai/fvm/default/bin