說明 | |
---|---|
首次發(fā)布 | 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
假設(shè)其存放的絕對路徑為
A
; -
2失尖、設(shè)置
flutter
命令全局有效(注意:如果使用了zsh
啊奄,終端啟動時~/.bash_profile
將不會被加載,解決辦法:修改~/.zshrc
文件雹仿,在其中添加:source ~/.bash_profile
)- a. 在 HOME 目錄下創(chuàng)建
.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" export PATH="$PATH:A/flutter/bin/cache/dart-sdk/bin"
- c. 保存后胧辽,執(zhí)行
source ~/.bash_profile
- a. 在 HOME 目錄下創(chuàng)建
-
3峻仇、安裝flutter依賴
flutter doctor
創(chuàng)建和運行工程
- 1、創(chuàng)建一個新工程
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
保存后人断,執(zhí)行
source ~/.bash_profile