代码拉取完成,页面将自动刷新
同步操作将从 Damon/ThinkFlutter 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env bash
download_dir=".flutter"
distribution_url="https://github.com/flutter/flutter.git"
#https://github.com/flutter/flutter.git 如果下载太慢可以使用 https://gitee.com/mirrors/Flutter.git
flutter_channel="stable"
flutter_version="1.12.13+hotfix.5"
# 初始化命令
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
if [[ "$(uname)" == *NT* ]] #判断是否是Windows系统,嵌套中括号是支持正则使用
then
flutter_command="$download_dir/bin/flutter.bat"
dart_command="$download_dir/bin/cache/dart-sdk/bin/dart.exe"
else
flutter_command="$download_dir/bin/flutter"
dart_command="$download_dir/bin/cache/dart-sdk/bin/dart"
fi
# 执行方法封装,支持flutterw dart 来运行dart文件
execFlutter() {
if [[ $1 == "dart" ]]
then
str=$*
substr=${str:4}
$dart_command $substr
else
$flutter_command $*
fi
}
# 下载
if [ ! -d $download_dir ]
then
echo "Create $download_dir dir"
mkdir $download_dir
fi
if [ ! -r $flutter_command ]
then
echo "Start download SDK:git clone -b $flutter_channel $distribution_url $download_dir"
git clone -b $flutter_channel $distribution_url $download_dir
if [ -r $flutter_command ]
then
# 下载dart sdk
echo "Downloading the Dart using the BITS service, Please wait a moment (maybe ten minutes or twenty minutes)..."
curFlutterVersion=`$flutter_command --version | grep '^Flutter' | cut -d ' ' -f2`
# 更新.android、.ios内部的flutter sdk路径
$flutter_command pub get
# 下载 某些 Flutter assets
$flutter_command doctor
echo "SDK download success:$curFlutterVersion"
else
echo "SDK download failed"
exit -1
fi
fi
# 切换版本
curFlutterVersion=`$flutter_command --version | grep '^Flutter' | cut -d ' ' -f2`
if [ $curFlutterVersion == $flutter_version ]
then
execFlutter $*
else
echo "Current version:$curFlutterVersion,Target version:$flutter_version"
$flutter_command channel $flutter_channel
$flutter_command upgrade
$flutter_command version -f "v$flutter_version"
# 下载dart sdk
echo "Downloading the Dart using the BITS service, Please wait a moment ..."
curFlutterVersion=`$flutter_command --version | grep '^Flutter' | cut -d ' ' -f2`
if [ $curFlutterVersion == $flutter_version ]
then
# 更新.android、.ios内部的flutter sdk路径
$flutter_command pub get
# 下载 某些 Flutter assets
$flutter_command doctor
echo "Change version success"
execFlutter $*
else
echo "Change version failed"
fi
fi
# 备注
# 获取某个命令的返回值 使用 STR=$(uname) 或者 STR=`uname`
# 变量赋值等号前后不能有空格 如 STR="123"
# shell if 是对空格敏感 如:if [ "dd" == "dd" ]
# if [[ "$(uname)" == *AA* ]] 嵌套中括号是支持正则使用
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。