终端运行flutter channel
命令查看当前flutter 环境 分支
Mac:~ mac$ flutter channel
Flutter channels:
master
dev
beta
* stable
带有*
号的为当前分支
切换分支命令 flutter channel 分支名
比如 flutter channel beta
和flutter channel dev
Mac:~ mac$ flutter channel dev
Switching to flutter channel 'dev'...
git: Switched to a new branch 'dev'
git: Branch 'dev' set up to track remote branch 'dev' from 'origin'.
Successfully switched to flutter channel 'dev'.
运行flutter channel
查看是否切换分支成功,如果本地没有要切换的分支命令会执行下载操作
Downloading Dart SDK from Flutter engine defa8be2b10650dad50dfee9324ed8d16eeec13f...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 175M 100 175M 0 0 10.0M 0 0:00:17 0:00:17 --:--:-- 10.2M
Building flutter tool...
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure
you trust this source!
Downloading Material fonts... 456ms
Downloading package sky_engine... 225ms
Downloading flutter_patched_sdk tools... 1,376ms
Downloading flutter_patched_sdk_product tools... 1,090ms
Downloading darwin-x64 tools... 3.1s
Downloading libimobiledevice... 27ms
Downloading usbmuxd... 47ms
Downloading libplist... 37ms
Downloading openssl... 166ms
Downloading ios-deploy... 29ms
Downloading darwin-x64/font-subset tools...
显示如下
Flutter channels:
master
* dev
beta
stable
即是切换分支成功。
如果报错信息如下:
git: error: Your local changes to the following files would be overwritten by checkout:
git: packages/flutter/lib/src/widgets/navigator.dart
git: Please commit your changes or stash them before you switch branches.
git: Aborting
Switching channels failed with error code 1.
cd
到本地flutter
环境目录下执行git checkout .
命令,再次执行切换分支的命令即可成功。