1. 安装独立的dart环境

官方安装方法:https://dart.dev/get-dart

brew tap dart-lang/dart
brew install dart
  • 更新dart版本:
brew upgrade dart
  • 重新安装dart
brew reinstall dart
  • 查看当前dart版本:
$ dart --version
Dart SDK version: 2.13.1 (stable) (Fri May 21 12:45:36 2021 +0200) on "macos_x64"
  • 查看当前安装的dart信息:
$ brew info dart
dart-lang/dart/dart: stable 2.13.1, HEAD
The Dart SDK
https://dart.dev
Conflicts with:dart-beta (because dart-beta ships the same binaries)
/usr/local/Cellar/dart/2.13.1 (508 files, 477.8MB) *Built from source on 2021-05-31 at 09:44:27
From: https://github.com/dart-lang/homebrew-dart/blob/HEAD/dart.rb
==> Options
--HEADInstall HEAD version
==> Caveats
Please note the path to the Dart SDK:/usr/local/opt/dart/libexec
  1. 安装fvm

命令:pub global activate fvm

$ pub global activate fvm
Package fvm is currently active at version 2.0.5.
Resolving dependencies... (3.4s)
The package fvm is already activated at newest available version.
To recompile executables, first run `global decativate fvm`.
Installed executable fvm.
Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):export PATH="$PATH":"$HOME/.pub-cache/bin"Activated fvm 2.0.5.
  1. 配置

.bash_profile中添加:

# fvm
export PATH="$PATH":"$HOME/.pub-cache/bin"

使.bash_profile生效:

source ~/.bash_profile

重启命令行工具,执行fvm

$ fvm
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 versionAvailable commands:config     Set configuration for FVMdart       Proxies Dart Commandsdoctor     Shows information about environment, and project configuration.flavor     Switches between different project flavorsflutter    Proxies Flutter Commandsglobal     Sets Flutter SDK Version as a globalinstall    Installs Flutter SDK Versionlist       Lists installed Flutter SDK Versionsreleases   View all Flutter SDK releases available for install.remove     Removes Flutter SDK Versionspawn      Spawns a command on a Flutter versionuse        Sets Flutter SDK Version you would like to use in a projectRun "fvm help <command>" for more information about a command.
  1. fvm相关命令

fvm官方使用文档

  • 配置fvm缓存路径(可选,默认在用户目录下fvm/versions文件夹):
fvm config --cache-path <CACHE_PATH>
  • 查看当前安装的flutter版本:
$ fvm listNo SDKs have been installed yet. Flutter. SDKs installed outside of fvm
will not be displayed.
  • 安装指定版本的flutter:
$ fvm install 2.2.1
Flutter "2.2.1" is not installed.Installing version: 2.2.1...
Cloning into '/Users/yuanzhiying/fvm/versions/2.2.1'...
  • 删除指定版本:
$ fvm remove 2.2.0
Removing 2.2.0...
2.2.0 removed.

此时会在用户目录下自动创建fvm/versions/2.2.1文件夹,如果本地已有flutter,可将本地的flutter拷贝到versions目录下,文件夹改为对应的版本名。当前flutter版本可以在flutter根目录下的version文件里查看。

/Users/yuanzhiying/fvm/versions/1.22.6
  • 查看汇漫网已安装的flutter版本:
$ fvm list
Cache Directory:  /Users/yuanzhiying/fvm/versions2.2.0
1.22.6
  • 查看环境信息和项目配置

FVM Version: 2.0.5
___________________________________________________FVM config found:
___________________________________________________Project: info_valley
Directory: /Users/yuanzhiying/mobile_life/info_valley
Version: 1.22.6
Project Flavor: None selected
___________________________________________________Version is currently cached locally.Cache Path: /Users/yuanzhiying/fvm/versions/1.22.6
Channel: false
SDK Version: 1.22.6IDE Links
VSCode: .fvm/flutter_sdk
Android Studio: /Users/yuanzhiying/mobile_life/info_valley/.fvm/flutter_sdkConfigured env paths:
___________________________________________________Flutter:Dart:
/usr/local/Cellar/dart/2.13.1/libexec/bin/dartFVM_HOME:
not set
  1. 使用对应版本的flutter:
    切换至项目目录,执行命令:
$ cd mobile_life/info_valley
$ fvm use 1.22.6
Project now uses Flutter [1.22.6]
HandshakeException: Connection terminated during handshake

查看当前的使用版本:

$ fvm list
Cache Directory:  /Users/yuanzhiying/fvm/versions2.2.0
1.22.6 (active)

项目目录下会生成一个隐藏文件夹.fvm

  1. 配置项目忽略文件.gitignore
.fvm/flutter_sdk
  1. 项目配置flutter路径

选择fluttersdk路径:

自动生成当前使用的flutter路径:

重启Android studio。

  1. flutter命令的使用

此时执行flutter doctor找不到flutter命令:

$ flutter doctor
zsh: command not found: flutter

所有flutter命令前加上fvm即可:

$ fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.3 20E232 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.5)
[✓] Android Studio (version 4.2)
[!] Connected device! Error: 营的iPhone is not connected. Xcode will continue when 营的iPhone is connected. (code -13)! Doctor found issues in 1 category.
$ fvm flutter pub get
Running "flutter pub get" in info_valley...                         1.4s
  1. flutterdart命令的使用

所有dart命令前加上fvm即可:

$ fvm dart --version
fvm: running Dart from Flutter "1.22.6"Dart SDK version: 2.10.5 (stable) (Tue Jan 19 13:05:37 2021 +0100) on "macos_x64"
  1. 便捷使用命令

.bash_profile中设置命令的别名:

# aliases 快捷使用fvm命令
alias f="fvm flutter"
alias d="fvm dart"

使生效:

source ~/.bash_profile

重启命令行工具。

$ f pub get
Running "flutter pub get" in info_valley...                         1.0s
$ d --version
Running using Flutter version configured in path.Dart SDK version: 2.13.1 (stable) (Fri May 21 12:45:36 2021 +0200) on "macos_x64"
  1. 设置全局默认的flutter版本
$ fvm global 1.22.6
Flutter "1.22.6" has been set as global
However your "flutter" path current points to:.
to use global Flutter SDK through FVM you should change it to:/Users/yuanzhiying/fvm/default/bin

此时fvm目录下自动生成了一个default的快捷文件夹。

使用fvm管理多个flutter版本相关推荐

  1. win下使用fvm实现多个Flutter版本的切换

    win下使用fvm实现多个Flutter版本的切换 配置前说明:Win环境下,下载FVM时,需要先配置一个Dart环境,因为用到 dart pub命令 配置Dart环境 a. 方式一:可以去Dart官 ...

  2. fvm切换多个Flutter版本

    fvm可以方便切换多个Flutter版本 FVM安装(MacOS) 1.安装Dart 2.Dart版本切换 3.安装FVM 4.FVM安装Flutter版本 5.FVM使用Flutter版本 1.安装 ...

  3. win10使用fvm实现多个Flutter版本的快捷切换

    下载 FVM 通过pub.dev下载,前提你得先单独安装一个Dart环境,点击获取. 通过命令 pub global activate fvm进行fvm的下载安装,耐心等待,网络不够好的,可能需要一些 ...

  4. fvm操作多个flutter的安装和使用教程

    win下使用fvm实现多个Flutter版本的切换 配置前说明:Win环境下,下载FVM时,需要先配置一个Dart环境,因为用到 dart pub命令 1. 配置Dart环境     a. 方式一:可 ...

  5. 使用FVM管理Flutter SDK版本切换

    window下配置fvm版本切换工具,管理flutter sdk版本的切换 一.配置flutter dart环境 使用前需要先配置flutter dart环境,才能下载jvm 已经配置好环境的,在命令 ...

  6. 【Windows环境下使用fvm管理多版本Flutter(flutter版本升级回退)】

    Windows环境下使用fvm管理多版本Flutter(flutter版本升级回退) 安装FVM 升级版本 升级后,使用方法二再次安装fvm 安装FVM 方式一: 使用choco安装fvm(当时环境中 ...

  7. 使用自动化插件release来管理maven项目的版本发布

    在实际开发过程中,特别是现在推崇的敏捷开发,项目版本的发布非常频繁,有可能是一周就一个版本.对于多模块构建的项目,如何在发布时统一升级项目版本,如果都由人来操作,很容易就漏改某个模块的版本,导致出现问 ...

  8. flyway常用配置_Spring Boot 2 实战:使用 Flyway 管理你数据库的版本变更

    1. 前言 随着项目的不断迭代,数据库表结构.数据都在发生着变化.甚至有的业务在多环境版本并行运行.数据为王的时代,管理好数据库的版本也成为了迫切的需要.如何能做到像 Git 之类的版本控制工具来管理 ...

  9. 使用codeplex管理WP7项目开发版本

    使用codeplex管理WP7项目开发版本 本篇文章介绍如何通过注册codeplex网站用户,创建codeplex项目,使用TFS连接codeplex,将WP7项目添加到TFS中,添加用户操作WP7项 ...

最新文章

  1. 利用CodeBERT,这个VS Code扩展可以自动生成Python文档字符串
  2. ios点击大头针气泡不弹出_百度地图使用(二)自定义大头针和弹出气泡
  3. CentOS 5.4 下配置FTP服务器 [转帖]
  4. selenium 4_Selenium4 Alpha –期望什么?
  5. 浅学习使用Ribbon 和 Feign的理解和使用
  6. python生成热度图_Python数据可视化 热力图
  7. 精通lambda表达式:java多核编程_Java8 Lambda表达式和流操作如何让你的代码变慢5倍...
  8. JAVAWeb使用POI做导出Excel
  9. python创建员工_Python综合练习之创建员工信息表
  10. the true story about using data mining to identify a relation between sales of beer and diapers
  11. oracle 12cora 03113,Oracle12.2 ORA-03113
  12. 2008年中国网游产业发展六大趋势
  13. 【云游戏】携手云流送,让普通终端也可畅享高端游戏画质
  14. Python图像绘制字符画
  15. 免拆机,Kindle固件版本5.10.3~5.13.3如何越狱?简单、易操作版
  16. kermit开发板启动Linux乱码,Ubuntu下C-kermit的使用
  17. 生活集思录-大学门外的事情
  18. GeneXus笔记Excel导入
  19. 结合高斯变异和维数决策逻辑的哈里斯鹰优化算法
  20. 大智慧新一代文件下载

热门文章

  1. Signal QQmlEngine::quit() emitted, but no receivers connected to handle it.
  2. 下载docx变成jsp_为什么我的电脑把doc 或word文件下载下来却变成了jsp
  3. Ubuntu树莓派安装macast实现DLNA投屏
  4. 测试用例-------一张白纸
  5. 原生JavaScript书写ajax请求
  6. 深度学习模型FLOPs详解
  7. 测试你的真实性格软件,测试你最真实的性格
  8. 免费申请基于飞腾硬件平台上的麒麟云试用!
  9. Java VO转PO(MapStruct使用)
  10. 局域网服务器和联通协议,联通局域网怎么设置