Flutter 开发环境配置

下载 Flutter SDK

Flutter SDK列表中文站
Flutter SDK列表英文站
下载对应系统SDK解压即可,比如解压到D:\flutter

配置环境变量

Flutter 默认仓库不能直接访问,需要配置国内代理地址,另外为了方便不同版本切换不用重新下载依赖,可以配置依赖缓存目录,默认缓存目录为SDK目录

用途 变量
基础库 FLUTTER_STORAGE_BASE_URL https://storage.flutter-io.cn
依赖库 PUB_HOSTED_URL https://pub.flutter-io.cn
依赖库缓存目录 PUB_CACHE %USERPROFILE%\.pub-cache

环境变量 PATH 配置加入,SDK解压目录

变量
FLUTTER_HOME Flutter SDK路径\bin
eg: D:\flutter
PATH %FLUTTER_HOME%\bin
%FLUTTER_HOME%\bin\cache\dart-sdk\bin

开发 Android 应用还需要配置 Android SDK,直接安装 Android Studio 根据引导下载即可(Android Studio安装可以跳过不需要手动配置)
Android Studio 国内下载地址
Android Studio 国外下载地址

变量
ANDROID_HOME Android SDK路径
eg: %USERPROFILE%\AppData\Local\Android\Sdk
PATH %ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin
%ANDROID_HOME%\platform-tools

macOS / Linux

# Flutter
export PUB_CACHE=~/.pub-cache
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export FLUTTER_HOME=~/Library/flutter
export DART_HOME=$FLUTTER_HOME/bin/cache/dart-sdk
export PATH=$PATH:$FLUTTER_HOME/bin:$DART_HOME/bin

# Java
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
export GRADLE_USER_HOME=~/.gradle

# Android
export ANDROID_HOME=~/Library/Android/sdk
# export ANDROID_SDK_ROOT=~/.android
export PATH=$PATH:$GRADLE_USER_HOME/shell/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools

检查配置

配置完成后需要在终端运行 flutter doctor
Android SDK授权协议flutter doctor --android-licenses

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