项目多了麻烦也随之而来,有的时间跨度大Flutter 版本管理起来就比较麻烦,之前一直都是本地下载多个版本,直到有点脑壳痛才开始使用 FVM,记录一下使用过程
1.安装 fvm
//下载较慢,耐心等待
brew tap leoafarias/fvm
brew install fvm
2.设置sdk安装目录
fvm config --cache-path <flutter sdk path>
//修改后可fvm config查看设置
➜ ~ fvm config
FVM Settings:
Located at /Users/***/fvm/.settings
cachePath: /Users/***/development
skipSetup: false
gitCache: false
3.安装指定版本 SDK
➜ ~ fvm install 3.7.3
Flutter "3.7.3" is not installed.
Installing version: 3.7.3...
Cloning into '/Users/***/development/3.7.3'...
4.查看所有已经安装的sdk
fvm list
5.设置全局sdk版本
fvm global 3.3.8
6.项目单独设置sdk版本
进入项目目录
fvm use 3.3.8
- vscode配置:
编辑 .vscode/settings.json
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
// Remove .fvm files from search
"search.exclude": {
"**/.fvm": true
},
// Remove from file watching
"files.watcherExclude": {
"**/.fvm": true
}
}
- Android Studio配置:
修改 .idea/workspace.xml,加入
<component name="VcsManagerConfiguration">
<ignored-roots>
<path value="$PROJECT_DIR$/.fvm/flutter_sdk" />
</ignored-roots>
</component>