参考: https://flutter.io/docs/get-started/install

mac安装flutter

1). 下载flutter

https://flutter.io/docs/get-started/install/macos

2). 环境配置.bashrc.zshrc。路径和实际存放位置对应,并source使之生效。

export PATH=/Users/tyrad/.flutter/bin:$PATH

3). 诊断flutter docker,并按提示操作。

➜  ~ 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
    ✗ 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 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
    ✗ 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)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3.2)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
    ! No devices available

! Doctor found issues in 5 categories.

启动项目

1). 命令行创建新项目:

flutter create myapp

遇到的问题: 卡在 > Running “flutter packages get” in myapp…”

解决方法见: https://flutter.io/community/china

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

2). 运行

真机:

20190130154882544155395.png

用Xcode打开ios工程, 登录个人账号,修改bunde_id。 让xcode自动生成免费的描述文件即可。 更简单的方法是是使用xcode运行。

模拟器:

20190130154882651782076.png

(ps:直接用Android Studio更佳)