1. 獲取Flutter SDK
https://flutter.io/docs/development/tools/sdk/archive?tab=macos#macos
解壓安裝包到想要的安裝的目錄
2. 配置環(huán)境變量
1.終端輸入
open .bash_profile
2.在彈出的文本框輸入
#for flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=$PATH:/Users/project/flutter/bin
這里/Users/project/flutter/bin是我的目錄,需要替換成自己的目錄
3.保存配置
source .bash_profile
3. 測試環(huán)境
終端輸入
flutter -h
如果看見關(guān)于Flutter的一些幫助信息,那么環(huán)境就配置好了
4. flutter doctor
運(yùn)行以下命令查看是否需要安裝其它依賴項來完成安裝
終端輸入flutter doctor
結(jié)果:
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale
zh-Hans-CN)
[?] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[?] iOS toolchain - develop for iOS devices
? Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
? 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 with Brew:
brew install ios-deploy
? CocoaPods not installed.
CocoaPods is used to retrieve the iOS platform side's plugin code that
responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work
on iOS.
For more info, see https://flutter.io/platform-plugins
To install:
brew install cocoapods
pod setup
[?] Android Studio (version 3.1)
[!] IntelliJ IDEA Ultimate Edition (version 2017.3.3)
? Flutter plugin not installed; this adds Flutter specific functionality.
? Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
注意不用每一個[x]和[i]都需要修復(fù)
如果只是用Flutter開發(fā)Android,那么出現(xiàn)上面輸出信息就可以了
開發(fā)ios需要按照提示補(bǔ)全配置
[?] iOS toolchain - develop for iOS devices
5.Android環(huán)境配置
- 安裝Android Studio ,配置Android Studio開發(fā)環(huán)境
- 打開Android Studio,在插件中搜索Flutter插件,安裝重啟Android Studio
完成以上5步,就可以開始開發(fā)Android平臺的Flutter應(yīng)用了