【Flutter 学习笔记一】Mac OS 安装 Flutter

前言

之前看了 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 即可

好了,安装还是比较简单的,当然你的电脑环境可能比较曲折

相关推荐