设置环境变量
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
note
国内其他可用的镜像站点:
上海交大 Linux 用户组
查看帮助文档: Flutter 镜像安装帮助, Pub 镜像安装帮助。
export PUB_HOSTED_URL=https://mirror.sjtu.edu.cn/dart-pub
export FLUTTER_STORAGE_BASE_URL=https://mirror.sjtu.edu.cn
清华大学 TUNA 协会
查看帮助文档: Flutter 镜像安装帮助, Pub 镜像安装帮助。
export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
下载SDK
假设你是Linux环境, 下载完成后执行以下命令设置环境:
tar xvf flutter_linux_3.3.10-stable.tar.xz # 解压SDK(每个人下载的flutter sdk版本可能不同)
export FLUTTER_HOME="YOUR_FLUTTER_DIRECTORY"
export PATH="$PATH:$FLUTTER_HOME/bin"
note
除了可以直接下载SDK使用外, 也可以clone官方仓库:
git clone -b dev https://github.com/flutter/flutter.git
export PATH="$PWD/flutter/bin:$PATH"
cd ./flutter
flutter doctor
开发
flutter create --template app \
--android-language kotlin \
--ios-language swift \
--project-name hello_world \
--org io.github.alanwei43 \
hello_world
Android环境变量
export ANDROID_HOME="YOUR_ANDROID_HOME_DIRECTORY"
export ANDROID_SDK_ROOT="$ANDROID_HOME/sdk"
# export ANDROID_AVD_HOME="$programs/.android/avd"