Flutter是谷歌的移動UI框架,可以快速在iOS和Android上構建高質量的原生用戶界面。 Flutter可以與現有的代碼一起工作。在全世界,Flutter正在被越來越多的開發者和組織使用,並且Flutter是完全免費、開源的。
Flutter中文網:https://flutterchina.club
1、獲取Flutter SDK 下載地址
2、配置環境變量
在cmd下執行:
open .bash_profile
在bash_profile文件添加以下
#Add the flutter tool to your path
#export PATH="$PATH:pwd
/flutter/bin"
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Applications/flutter/bin:$PATH
注意/Applications/flutter爲你的存放flutter文件夾的路徑。
保存cmd下再執行
source ~/.bash_profile
3、查看是否完成
運行以下命令查看是否需要安裝其它依賴項來完成安裝:
flutter doctor
嘿嘿 有幾個問題,我們依次解決
【1】、Android toolchain - develop for Android devices (Android SDK version 28.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
–android-licenses
本機已安裝了AndroidSDK,Android許可不被接受,需要執行以下命令,同意許可
flutter doctor --android-licenses
---------------------------------------
Accept? (y/N): y
All SDK package licenses accepted
【2】、Xcode - develop for iOS and macOS
✗ 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
本機已安裝了xcode,那就是需要執行以下命令
cmd
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
再執行一下,看看這兩個問題解決了沒
flutter doctor
ok,已解決,繼續解析以下問題
【3】、Android Studio (version 3.4)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
本機已安裝Android Studio,但是缺這兩個插件,需要我們去安裝一下。
打開Android Studio ->configure->Plugins
搜索flutter 進行install
搜索dart 進行install
【4】Connected device
! No devices available
本機連接設備,可忽略
再執行一下
flutter doctor
紅叉問題都已解決