【Flutter 學習筆記一】Mac OS 安裝 Flutter

enda發表於2019-02-16

前言

之前看了 Google 釋出的 Flutter ,一直沒有機會嘗試,最近需要做一個 App,所以讓我有機會嘗試一下。
React-Native 我用的比較熟,如果選擇用 RN ,我的工作很快就能完成,但是我還是決定選擇 Flutter。

在專欄中,我會記錄從零開始,開發出一個完整 App 的一些過程和筆記。
學習文件我會參考 Flutter 官方文件

如果中途棄坑,各位勿怪~

好了,轉入正題,這篇記錄一下在 Mac OS 上安裝 Flutter 的一些過程

安裝

安裝非常簡單,就是把程式碼 clone 下來,加入環境變數即可

git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

中國映象

由於 flutter 有些命令需要聯網,所以為了速度我們需要加一個映象

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

環境檢查

在安裝完成之後,我們執行 doctor 來檢查一下

flutter doctor

執行之後,我們電腦輸入內容如下


[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.5 17F77, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    ✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
        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)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected devices
    ! No devices available

! Doctor found issues in 3 categories.

[!] 這個符號的,都是需要我們去解決的,解決方法也特別簡單,按照提示執行命令即可

比如:

[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses 

我們按照提示執行 flutter doctor --android-licenses 即可

好了,安裝還是比較簡單的,當然你的電腦環境可能比較曲折?

關於 Android SDK 和 Android Studio 等配置,可參考我釋出的另一篇文章 https://segmentfault.com/a/11…

當然大家也可以加群一起學習~ (826912082)

學習資源

1.官方文件

2.中文文件

相關文章