1 Star 0 Fork 3

yanglbsjz/ThinkFlutter

forked from Damon/ThinkFlutter 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
flutterw 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
MasonLiuChn 提交于 2020-01-18 11:14 . first commit
#!/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* ]] 嵌套中括号是支持正则使用
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Dart
1
https://gitee.com/yanglbsjz/ThinkFlutter.git
[email protected]:yanglbsjz/ThinkFlutter.git
yanglbsjz
ThinkFlutter
ThinkFlutter
master

搜索帮助