说明 | |
---|---|
首次发布 | 2019年03月27日 |
最近更新 | 2019年06月15日 |
╔════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - https://flutter.io ║
║ ║
║ The Flutter tool anonymously reports feature usage statistics and crash ║
║ reports to Google in order to help Google contribute improvements to ║
║ Flutter over time. ║
║ ║
║ Read about data we send with crash reports: ║
║ https://github.com/flutter/flutter/wiki/Flutter-CLI-crash-reporting ║
║ ║
║ See Google's privacy policy: ║
║ https://www.google.com/intl/en/policies/privacy/ ║
║ ║
║ Use "flutter config --no-analytics" to disable analytics and crash ║
║ reporting. ║
╚════════════════════════════════════════════════════════════════════════════╝
下面开始正题:
安装Flutter
-
1、下载 Flutter SDK,必须用 git clone,方便安装依赖。
git clone -b stable https://github.com/flutter/flutter.git
假设其存放的绝对路径为
A
; -
2、设置
flutter
命令全局有效(注意:如果使用了zsh
,终端启动时~/.bash_profile
将不会被加载,解决办法:修改~/.zshrc
文件,在其中添加:source ~/.bash_profile
)- a. 在 HOME 目录下创建
.bash_profile
文件touch ~/.bash_profile
- b. 配置
.bash_profile
信息,需要特别注意的是:最后一个命令里的A
就是Flutter SDK
在你电脑里的绝对路径。export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn export PATH="$PATH:A/flutter/bin"
- c. 保存后,执行
source ~/.bash_profile
- a. 在 HOME 目录下创建
-
3、安装flutter依赖
flutter doctor
创建和运行工程
- 1、创建一个新工程
flutter create my_app
- 2、运行
cd my_app
flutter run
FAQ:
- 1、运行iOS模拟器报错:
ERROR: Could not connect to lockdownd, error code -17
解决:
brew install --HEAD libimobiledevice -g
brew install ideviceinstaller -g
sudo chmod -R 777 /var/db/lockdown
拓展
配置AndroidStudio 的 adb:
打开~/.bash_profile
,添加以下代码:
ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
保存后,执行
source ~/.bash_profile
网友评论