提示:
正式版FlutterSDK为1.20.2,.tar文件44.1 MB
最新FlutterSDK1.21.0-9.1.pre版完整的相关文件1.99GB
1、下载Flutter SDK
1.1终端cd 到想要安装Flutter SDK到目录
cd +存放路径
1.2执行下面指令就会下载SDK文件夹“flutter”
git clone https://github.com/flutter/flutter.git
或者
git clone -b master https://github.com/flutter/flutter.git
稳定版
git clone -b beta https://github.com/flutter/flutter.git
使用beta版。
经过等待终于下载完
Macbook@ % cd /Users/Macbook/Documents/Flutter
Macbook@ Flutter % git clone https://github.com/flutter/flutter.git
Cloning into 'flutter'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 257017 (delta 11), reused 7 (delta 0), pack-reused 256983
Receiving objects: 100% (257017/257017), 110.01 MiB | 55.00 KiB/s, done.
Resolving deltas: 100% (197622/197622), done.
Updating files: 100% (4933/4933), done.
文件夹结构如下图:
2、配置.bash_profile
2.1打开根目录文件夹open ~
或查看文件内容open -e .bash_profile
2.2创建/编辑文件:vim ~/.bash_profile
,
2.3输入内容:
// 用户需要设置,不要照搬
export PATH=${PATH}:~/document/code/flutter/bin
// 再加上Flutter官方为中国开发者搭建了临时镜像:
export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
注意:PATH_TO_FLUTTER_GIT_DIRECTORY 为你flutter的路径,比如“~/document/code”,至内部bin文件夹
export PATH=${PATH}:PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin
或者
export PATH=PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
户需要设置
export PATH=${PATH}:~/document/code/flutter/bin
//或者
export PATH=~/document/code/flutter/bin:$PATH
3、检测是否配置完成
3.1刷新当前终端窗口source ~/.bash_profile
3.2执行 flutter -h
或flutter doctor
-h成功会展示Flutter指令说明:
Manage your Flutter app development.
doctor成功会展示Android和Xcode环境模拟器运行设备配置情况
Doctor summary (to see all details, run flutter doctor -v):
3.3结果用如图用勾叉表示,成功为打勾,错误为打叉。
正常情况下最近的MacOS下载的Xcode最新版,是成功的。
安卓的是配置失败的,已经下载有Android Studio。下图有提示解决方法:执行 flutter doctor --android-licenses
授权,和插件PluginFlutter
与Dart
未安装,插件安装去Android Studio搜索安装就行。
如果是手动去下载SDK,执行
flutter -h
或flutter doctor
可能会报错,缺失文件,所以是建议用上面指令去下载SDK。
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
to install Flutter, see the instructions at:
https://flutter.dev/get-started
如果后续使用过程中,想切换SDK版本,可以执行
flutter channel
查看有什么渠道版本,执行flutter channel <渠道分支名称>
和flutter upgrade
可以直接切换。
渠道分支名称
Flutter channels:
master 主分支
dev 开发版
beta 测试版
* stable 稳定版(带*表示当前使用的分支,线上开发推荐稳定版)
flutter channel stable
flutter upgrade
4、完成
后续可以创建项目flutter create FlutterDemo
,需要权限就在前面加上sudo