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
红叉问题都已解决