Flutter 学习笔记《一》

Flutter  安装for macOS

需要环境 

1、添加flutter相关工具到path中:

bash, mkdir, rm, git, curl, unzip, which

2、去flutter官网下载其最新可用的安装包 

git clone -b master https://github.com/flutter/flutter.git
./flutter/bin/flutter --version

3、解压安装包到你想安装的目录,如 

cd ~/development
unzip ~/Downloads/flutter_macos_v0.5.1-beta.zip

4、添加flutter相关工具到path中:

 

export PATH=`pwd`/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

5、运行 flutter doctor

运行以下命令查看是否需要安装其它依赖项来完成安装

flutter doctor

6、安装xcode和Android Studio和Fultter依赖

7、更新环境变量

  1. 确定您Flutter SDK的目录,您将在步骤3中用到。
  2. 打开(或创建) $HOME/.bash_profile. 文件路径和文件名可能在您的机器上不同.
  3. 添加以下行并更改[PATH_TO_FLUTTER_GIT_DIRECTORY]为克隆Flutter的git repo的路径:

   PATH_TO_FLUTTER_GIT_DIRECTORY 为你flutter的路径,比如“~/document/code” 

export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
export PATH=PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
export PATH=~/document/code/flutter/bin:$PATH

8、运行 source $HOME/.bash_profile 刷新当前终端窗口.

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

9、通过运行flutter/bin命令验证目录是否在已经在PATH中:

echo $PATH

 

 

你可能感兴趣的:(Flutter)