1.下載Flutter SDK
一.、使用git克隆Flutter,命令:git clone -b beta https://github.com/flutter/flutter.git;
二、從官網(wǎng)下載flutter,https://flutter.io/setup-macos/;
2.配置環(huán)境變量
在當(dāng)前用戶目錄下創(chuàng)建.bash_profile文件,如果該文件已經(jīng)存在,則直接打開(kāi).
打開(kāi)配置文件
open -e .bash_profile
配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/hujintao/flutter/bin:$PATH
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
export RN=/usr/local/bin
export PATH=$RN:$PATH
GRADLE_HOME=/Users/Apple/Desktop/soft/gradle/gradle-4.6
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
其他問(wèn)題解決
終端執(zhí)行命令flutter doctor 檢測(cè)安裝依賴
? libimobiledevice and ideviceinstaller are not installed. To install with
Brew, run:
brew update
brew install --HEAD usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
? ios-deploy not installed. To install:
brew install ios-deploy
[!] Android Studio (version 3.4)
? Flutter plugin not installed; this adds Flutter specific functionality.
? Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2018.1.4)
? Flutter plugin not installed; this adds Flutter specific functionality.
? Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.35.1)
? Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
android studio 配置
解決方案:打開(kāi)android studio, 打開(kāi)plugin;
輸入flutter搜索,點(diǎn)擊中間的 Search in repositories;
需要安裝兩個(gè)插件:
- Flutter插件: 支持Flutter開(kāi)發(fā)工作流 (運(yùn)行、調(diào)試、熱重載等).
- Dart插件: 提供代碼分析 (輸入代碼時(shí)進(jìn)行驗(yàn)證、代碼補(bǔ)全等).
要安裝這些: - 點(diǎn)擊install,安裝完畢之后重啟android studio;
配置模擬器
成功的標(biāo)志

成功的標(biāo)志.jpg
3.創(chuàng)建新項(xiàng)目

創(chuàng)建新項(xiàng)目1.jpg

創(chuàng)建新項(xiàng)目2.jpg

創(chuàng)建新項(xiàng)目3.jpg

創(chuàng)建新項(xiàng)目4.jpg
Run the app

Run the app.jpg
//終端下建個(gè)文件夾,用命令創(chuàng)建一個(gè)flutter項(xiàng)目
1. flutter create myapp
//進(jìn)入項(xiàng)目
2. cd myapp
//run起來(lái)
3. flutter run
效果圖:
Android

Android.jpg
iOS

iOS.jpg
運(yùn)行在所有可用設(shè)備
flutter run -d all