Mac下安装flutter

594 阅读1分钟

进入到安装的目录下,终端执行以下命令

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
git clone -b beta https://github.com/flutter/flutter.git
export PATH="$PWD/flutter/bin:$PATH"
cd ./flutter

执行

flutter doctor

检测flutter环境

[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14 18A391, 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
    ✗ Brew can be used to install tools for iOS device development.
      Download brew at https://brew.sh/.
[!] Android Studio (not installed)
[!] VS Code (version 1.29.1)
[✓] Connected device (1 available)

以上结果代表flutter环境已安装好,但是andriod跟ios的工具没安装好,根据提示安装就可。如何没有安装homebrew,使用以下命令安装即可

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

创建项目

进入vs code执行Cmd+Shift+P选择Flutter: new project,输入项目名称