Flutter環(huán)境搭建

谷歌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 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

WX20181222-001326@2x.png

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。
WX20181224-101954@2x.png

plugins中搜索庫(kù)flutter:
WX20181224-102053@2x.png

WX20181224-102236@2x.png


其他問(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!
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 本文主要介紹Flutter相關(guān)的東西,包括Fuchsia、Dart、Flutter特性、安裝以及整體架構(gòu)等內(nèi)容。 ...
    Q吹個(gè)大氣球Q閱讀 8,030評(píng)論 8 49
  • 本篇為Flutter中文教程系列第一篇,先整體介紹一下Flutter,旨在讓您對(duì)Flutter有一個(gè)基本的認(rèn)識(shí)。如...
    lazydu閱讀 13,081評(píng)論 2 38
  • Flutter 的第一次嘗試 什么是 Flutter? Flutter是谷歌的移動(dòng)UI框架,可以快速在iOS和An...
    cpacm閱讀 1,026評(píng)論 0 0
  • 開(kāi)篇 開(kāi)局一張圖,其他全靠_? 目前flutter框架還比較新,又是谷歌家的東西,所以網(wǎng)上的文章基本都是講安卓和f...
    華南犀牛閱讀 17,976評(píng)論 22 47
  • 一、Flutter是什么? 根據(jù)Flutter中文官網(wǎng)(英文官網(wǎng))的解釋:Flutter是谷歌的移動(dòng)UI框架,可以...
    鴻羽羽羽羽羽閱讀 1,000評(píng)論 4 13

友情鏈接更多精彩內(nèi)容