Flutter环境搭建

Flutter SDK下载

下载SDK:
https://flutter.dev/docs/development/tools/sdk/releases

配置环境变量

环境变量配置文件路径: ~/.bash_profile

1
2
3
export FLUTTER_HOME=/YourPath/flutter
export PATH=$PATH:$FLUTTER_HOME/bin
export PATH=$PATH:$FLUTTER_HOME/bin/cache/dart-sdk/bin

然后通过命令: source ~/.bash_profile重新加载即可。

对终端使用zsh的系统版本,环境变量路径为:~/.zshrc

可以通过命令echo $PATH查看环境变量。

遇到的问题

问题描述:

Exception: Flutter failed to create a directory at “YourPath/flutter”. The flutter tool cannot access the file or directory.

解决: sudo chown -R $USER path