Mac 搭建 Flutter 开发环境

2019-11-26  本文已影响0人  iVikings

1、下载 Flutter SDK 包:https://flutter.io/setup-macos/
2、将文件提取到所需位置,我存放在根目录的 opt 下,/opt/flutter(仅供参考,安装在哪看自己习惯)

cd /opt
sudo unzip ~/Downloads/flutter_macos_v1.9.1+hotfix.6-stable.zip

3、配置环境变量

vim ~/.bash_profile
vim ~/.zshrc
# Pub 源(镜像)配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

# flutter 环境变量
export FLUTTER_ROOT=/opt/flutter
export FLUTTER=$FLUTTER_ROOT/bin
export PATH=$FLUTTER:$PATH

# dart 环境变量
export PATH=$FLUTTER/cache/dart-sdk/bin:$PATH

说明:

export FLUTTER_ROOT=你的 flutter 安装目录

source ~/.bash_profile
source ~/.zshrc

4、检测是否安装完成

flutter -h

5、运行以下命令以查看是否需要安装任何依赖关系才能完成设置(对于详细输出,请添加 -v 标志):

flutter doctor

若提示没权限,终端执行下面命令:

sudo chown -R $USER /opt/flutter

6、Android Studio`下载地址:http://www.android-studio.org/

7、Visual Studio 下载地址:https://code.visualstudio.com/

8、插件安装https://www.jianshu.com/p/883da016b2ef


参考:

上一篇下一篇

猜你喜欢

热点阅读