获取Flutter SDK
-
去flutter官网下载其最新可用的安装包,转到下载页 。
注意,Flutter的渠道版本会不停变动,请以Flutter官网为准。另外,在中国大陆地区,要想正常获取安装包列表或下载安装包,可能需要翻墙,读者也可以去Flutter github项目下去下载安装包,转到下载页 。
-
解压安装包到你想安装的目录,如:
cd ~/development unzip ~/Downloads/flutter_macos_v0.5.1-beta.zip
-
添加
flutter
相关工具到path中:export PATH=`pwd`/flutter/bin:$PATH
-
运行 flutter doctor
运行以下命令查看是否需要安装其它依赖项来完成安装:flutter doctor
该命令检查您的环境并在终端窗口中显示报告。Dart SDK已经在捆绑在Flutter里了,没有必要单独安装Dart。 仔细检查命令行输出以获取可能需要安装的其他软件或进一步需要执行的任务(以粗体显示)
如果你是download的release包,运行flutter doctor会报如下错误:
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
to set up Flutter, run the following command:
git clone -b beta https://github.com/flutter/flutter.git
解决方案:
- 在flutter目录执行 git init。不推荐
- git clone https://github.com/flutter/flutter.git
或者按官方推荐使用beta分支。
git clone -b beta https://github.com/flutter/flutter.git
网友评论