Flutter mac 环境配置

主要参考 入门: 在macOS上搭建Flutter开发环境

1.下载Flutter SDK 下载页

  • 1.下载后解压
  • 2.将解压包放到一个指定目录: 如, 我将它放在了/Users/用户名/Documents/flutter 目录下

2.更新环境变量, 配置bash_profile文件

    1. 启动终端Terminal

    ~/.bash_profile

    No such file or directory, 如果已经存在, 则直接跳过执行 第 4 步. 编辑.bash_profile文件

    1. 进入当前用户的home目录

    输入cd ~

    1. 创建.bash_profile

      输入touch .bash_profile

    1. 编辑.bash_profile文件

      输入open -e .bash_profile

  • 5 输入一下命令

    export PUB_HOSTED_URL=https://pub.flutter-io.cn 
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn 
    export PATH='PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin':$PATH // 解压包所在电脑文件下的bin目录
    // 如,我电脑为: export PATH= /Users/自己的用户名/Documents/flutter/flutter_macos_v1.9.1+hotfix.6-stable/bin:$PATH
    
    1. 保存文件,关闭.bash_profile
    1. 更新刚配置的环境变量

      输入source .bash_profile

3.Android 和 iOS 开发环境配置不在累赘

4.运行 flutter doctor

flutter doctor

执行结果:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G103, locale
    zh-Hans-CN)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.39.2)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

你可能感兴趣的:(Flutter mac 环境配置)