谷歌Flutter官方網(wǎng)站
Flutter中文網(wǎng)
Flutter社區(qū)中文資源
Flutter初體驗(yàn)(一)——Mac 安裝配置
如果你在國(guó)內(nèi)使用 Flutter,那么你可能需要找一個(gè)與官方同步的可信的鏡像站點(diǎn),幫助你的 Flutter 命令行工具到該鏡像站點(diǎn)下載其所需的資源。
你需要為此設(shè)置兩個(gè)環(huán)境變量:“PUB_HOSTED_URL”和“FLUTTER_STORAGE_BASE_URL”,然后再運(yùn)行 Flutter 命令行工具,查看設(shè)置教程。
上海交通大學(xué) Linux 用戶組
FLUTTER_STORAGE_BASE_URL: https://mirrors.sjtug.sjtu.edu.cn
PUB_HOSTED_URL: https://dart-pub.mirrors.sjtug.sjtu.edu.cn
Flutter 社區(qū)
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
PUB_HOSTED_URL: https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
注意:我們無(wú)法保證這些鏡像網(wǎng)站得以長(zhǎng)期維護(hù)和運(yùn)行,請(qǐng)慎重選擇一些可信的鏡像網(wǎng)站。
下載flutter stable:https://flutter.dev/docs/get-started/install/macos
- 配置永久環(huán)境變量:
1、將下載的flutter包放在/Users/yuanzhiying/Library/下
2、執(zhí)行命令:
open ~/.bash_profile
如果不存在.bash_profile,則執(zhí)行cd ~和touch .bash_profile來(lái)創(chuàng)建一個(gè).bash_profile
3、打開(kāi)文件,在里面添加上:
# flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=${PATH}:/Users/yuanzhiying/Library/flutter/bin
4、執(zhí)行
source ~/.bash_profile
5、驗(yàn)證
echo $PATH
6、執(zhí)行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.2 18C54, locale
zh-Hans-CN)
[?] Android toolchain - develop for Android devices
? Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.io/setup/#android-setup for detailed
instructions).
If Android SDK has been installed to a custom location, set $ANDROID_HOME
to that location.
You may also want to add it to your PATH environment variable.
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
? 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
[!] Android Studio (not installed)
[?] Connected device (1 available)
! Doctor found issues in 3 categories.
按照上面的提示安裝不合要求的項(xiàng)目。
7、 iOS toolchain按照命令即可安裝成功。
8、安裝android-studio
下載android-studio:
https://developer.android.com/studio/index.html (最新版)
dmg包雙擊安裝即可
9、打開(kāi)android studio,按提示安裝Android sdk

10、安裝Android studio plugin:Flutter dart
搜索不到無(wú)法下載,按下面的處理方法:
File->Settings->Apparence & Behavior->System Settings->Updates->use secure connnection 勾去掉
11、Android Studio、IntelliJ IDEA安裝Flutter plugin和Dart plugin
先去掉Android studio中updates的Use secure connection的勾選,點(diǎn)擊應(yīng)用apply。

plugins中搜索庫(kù)flutter:


其他問(wèn)題解決辦法:
一、Android license status unknown
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
? Android license status unknown.
執(zhí)行:
flutter doctor --android-licenses
結(jié)果:
yuanzhiying:~ yuanzhiying$ flutter doctor --android-licenses
Warning: File /Users/yuanzhiying/.android/repositories.cfg could not be loaded.
All SDK package licenses accepted.======] 100% Computing updates...
yuanzhiying:~ yuanzhiying$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.2 18C54, locale zh-Hans-CN)
[?] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[?] iOS toolchain - develop for iOS devices (Xcode 10.1)
[?] Android Studio (version 3.3)
[?] IntelliJ IDEA Ultimate Edition (version 2018.1.4)
[?] Connected device (2 available)
? No issues found!