针对有的时候,
一些旧代码不能用最新的flutter 版本编译
或者本地版本久,要看别人的demo得用最新的版本才可以
如果每次都 git reset --hard 或者 flutter upgrade 都非常费时间,能简单便捷实现切换最好
- 首先下载不同的版本 sdk,比如我目前有 v1.12 v.120 两个版本
[✓] Flutter (Channel dev, v1.12.13+hotfix.9, on Mac OS X 10.15.5 19F101, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.46.1)
[✓] Connected device (2 available)
和
[✓] Flutter (Channel dev, 1.20.0-2.0.pre, on Mac OS X 10.15.5 19F101, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.46.1)
[✓] Connected device (3 available)
- VScode 配置
因为PATH环境只能配置一个,那在VSCODE settings 里边会有一个可以配置 dart path 地方
对应的内容为
{
"dart.flutterSdkPath": "/Users/lukeyan/flutterLatest/flutter",
"terminal.integrated.shell.osx": "/bin/bash",
"editor.quickSuggestions": {
"strings": true
},
"window.zoomLevel": 0,
"workbench.iconTheme": "material-icon-theme",
"dart.openDevTools": "flutter",
"minapp-vscode.disableAutoConfig": true,
"dart.warnWhenEditingFilesOutsideWorkspace": false,
"dart.flutterSdkPaths":
"/Users/lukeyan/flutter",
"/Users/lukeyan/flutterLatest/flutter"
]
}
我看别人说运行项目后,点击状态栏可以切换版本
但是我自己的不起作用,就直接改
"dart.flutterSdkPath": "/Users/lukeyan/flutterLatest/flutter",
这句为你要用的版本,重新编译可以了
网友评论