初识Flutter-环境搭建记录

  |   0 评论   |   325 浏览

步骤参考 Flutter中文网

1.首先下载sdk,有两种方式,官网下载和github下载,我这里是直接从github下载
image.png
2.将下载下来的zip解压到你想安装的路径下, 注意,不要将flutter安装到需要一些高权限的路径如C:\Program Files\
3.设置用户环境变量
将解压后的目录的bin目录追加到用户环境变量Path后
再添加变量PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL

PUB_HOSTED_URL=https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

image.png

一切OK后运行命令

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

解决方法:
在想要安装的目录中运行(我这里是翻墙后才clone成功)
git clone -b beta https://github.com/flutter/flutter.git
然后将用户环境变量Path中刚才我们添加的bin的路径改为这个新clone后的bin路径,再次运行flutter doctor
image.png
如果用as的话还需要安装flutter和dart的插件,idea我已经装好了,所以可以开始用idea开发flutter了!

再补充一个小坑,就是clone下来flutter的sdk后,里面已经自带了dart的sdk,当编辑器创建了flutter project后,需要指定dart的sdk path,这个路径在flutter目录的\bin\cache\dart-sdk下面


作者:wenbo

评论

发表评论