Flutter mac安装笔记

本文最后更新于:2023年8月15日 下午

flutter mac安装笔记

1、设置环境变量

vim ~/.bash_profile      进入编辑模式 i

由于在国内访问Flutter有时可能会受到限制,Flutter官方为中国开发者搭建了临时镜像,大家可以将如下环境变量加入到用户环境变量中:

1
2
3
export PUB_HOSTED_URL=[https://pub](https://pub/).[flutter-io.cn](http://flutter-io.cn/)

export FLUTTER_STORAGE_BASE_URL=[https://storage](https://storage/).[flutter-io.cn](http://flutter-io.cn/)

2、安装flutter

下载地址:https://flutter.dev/docs/development/tools/sdk/releases#macos   要翻墙

解压sdk到一个位置

添加flutter环境变量到path中,然后就报错了:

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

尝试提示的解决方案:不过我下载了stable分支

git clone -b stable   https://github.com/flutter/flutter.git

配置环境变量:  export PATH=/Users/kele/Desktop/workspace/flutterSDK/bin:$PATH

刷新当前窗口:source ~/.bash_profile

注意: 如果你使用的是zsh,终端启动时 ~/.bash_profile 将不会被加载,解决办法就是修改 ~/.zshrc ,在其中添加:source ~/.bash_profile

SDK搞定

3、配置开发环境

flutter doctor

按照提示安装即可

安装AndroidStudio不用设置代理,也不用安装jdk,as是自带jdk的

参考链接:

https://book.flutterchina.club/chapter1/install_flutter.html


Flutter mac安装笔记
http://bestkele.cn/2020/08/05/flutter/flutter-mac/
作者
kele
发布于
2020年8月5日
许可协议