Mac环境搭建flutter并配置环境变量

Windows环境搭建flutter

https://blog.csdn.net/ytfunnysite/article/details/81070066git

克隆项目

  • git clone https://github.com/flutter/flutter.git

配置变量,使用中国镜像

  1. 进入当前用户的home目录 输入
cd ~
  1. 建立.bash_profile 输入
touch .bash_profile
  1. 编辑.bash_profile文件
open -e .bash_profile
  1. 配置镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
  1. command + s保存文件
  2. 更新配置的环境变量
source .bash_profile
  1. 验证PATH
echo $PATH
  1. .bash_profile文件配置ANDROID_HOME环境变量:
export ANDROID_HOME=/program/sdk
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/28.0.3
  1. 查看当前flutter版本分支
flutter channel
  1. 切换flutter稳定版stable分支
flutter channel stable
  1. 查看和升级flutter版本
flutter --version
flutter upgrade

使用压缩包

若是没有在线下载,而是使用的官方压缩包,能够经过.zshrc配置环境变量github

cd ~
touch .zshrc
open -e .zshrc

打开.zshrc 后配置解压的flutter路径 export PATH="$PATH:/Library/flutter/bin"保存后刷新配置bash

source $HOME/.zshrc 
echo $PATH  //验证环境变量
相关文章
相关标签/搜索