flutter

Flutter Mac环境配置

2020-08-19  本文已影响0人  zombie

1.下载SDK

 export PUB_HOSTED_URL=https://pub.flutter-io.cn
 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
 git clone https://github.com/flutter/flutter.git -b stable

2.配置环境变量

touch .bash_profile // 创建bash_profile
open .bash_profile // 打开bash_profile 
source .bash_profile  // 更新bash_profile

打开bash_profile文件 添加如下环境变量

 export PUB_HOSTED_URL=https://pub.flutter-io.cn
 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
 export Flutter_Home=/Users/xxxx/flutter   // 这个路径为Flutter安装目录
 export PATH=$PATH:$Flutter_Home/bin
 export PATH=$PATH:$Flutter_Home/bin/cache/dart-sdk/bin

添加完成之后 执行source .bash_profile更新环境变量,可以执行echo $PATH查看环境变量是否生效

touch .zshrc   // 创建zshrc 
open .zshrc   // 打开zshrc
source .zshrc  //更新zshrc

3.查看版本,会自动下载sdk

flutter --version

4.开发二进制文件预下载(可选操作)

flutter precache 

下载不同平台的开发二进制文件,如果需要一个封闭式的构建环境,或在网络可用性不稳定的情况下使用等情况,可能需要通过这个命令预先下载 iOS 和 Android 的开发二进制文件

5.平台的配置

下载Android Studio或者VSCode 在对应IDE中下载Flutter和Dart插件,可以执行flutter doctor验证是否安装成功,以下为配置成功截图

上一篇 下一篇

猜你喜欢

热点阅读