mirror-web/help/_posts/2019-02-27-flutter.md
Miao Wang 96c01f1658
Re-locate files
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
2020-08-06 15:18:27 +08:00

64 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
category: help
layout: help
mirrorid: flutter
---
# Flutter 镜像安装帮助
Flutter 是 Google 开源的 UI 工具包帮助开发者通过一套代码库高效构建多平台精美应用支持移动、Web、桌面和嵌入式平台。
获取最新稳定版 Flutter SDK 安装包可从 [镜像站下载](https://{{ site.hostname }}/flutter/flutter_infra/releases/stable/)。
Flutter 开发依赖于 [SDK 的升级](https://flutter.cn/docs/development/tools/sdk/upgrading) 和 [Dart Package 生态](https://pub.flutter-io.cn/)
因此,如果您的网络访问 Google 受阻,需要将您开发设备的如下两个环境变量设置指向 TUNA 镜像站:
- `PUB_HOSTED_URL`
- `FLUTTER_STORAGE_BASE_URL`
设定方式如下:
```bash
export FLUTTER_STORAGE_BASE_URL="https://{{ site.hostname }}/flutter"
export PUB_HOSTED_URL="https://{{ site.hostname }}/dart-pub"
```
若希望长期使用 TUNA 镜像:
```bash
echo 'export FLUTTER_STORAGE_BASE_URL="https://{{ site.hostname }}/flutter"' >> ~/.bashrc
echo 'export PUB_HOSTED_URL="https://{{ site.hostname }}/dart-pub"' >> ~/.bashrc
```
在编译android项目时flutter还会从 https://storage.googleapis.com/download.flutter.io 下载Java程序库您可以在 Android 项目目录下的 build.gradle 中添加下面一行下载源从而使用TUNA镜像。
```
allprojects {
repositories {
google()
jcenter()
maven { url 'https://mirrors.tuna.tsinghua.edu.cn/flutter/download.flutter.io' }
}
}
```
Flutter SDK 的更新会从 Github 获取,如您的开发设备访问 Github 速度慢,可以在 **开发设备的 Flutter SDK 目录** 运行下面的命令,将 Git 上游设置为 TUNA 镜像:
```
git remote set-url origin https://{{ site.hostname }}/git/flutter-sdk.git
```
或者通过下面的命令,直接从 Master 构建渠道检出 Flutter 的 SDK
```
git clone -b master https://{{ site.hostname }}/git/flutter-sdk.git
./flutter-sdk/bin/flutter --version
```
您也可以替换上述代码中 `git clone -b` 之后的 `master``beta` 获取 Beta 渠道的构建、替换为 `dev` 获取 Dev 渠道的构建。
稳定版的构建可以通过修改 `master``stable` 获得,也可以帮助文档最上方提到的,通过 [镜像站直接下载](https://{{ site.hostname }}/flutter/flutter_infra/releases/stable/)。
如果您想单独设定 Dart 语言的包管理器 Pub其镜像使用方法参见 [Pub 镜像安装帮助](../dart-pub/)。
更多 Flutter 资源和中文文档,
请访问 [Flutter 中文资源网站 (flutter.cn)](https://flutter.cn) 和 [Dart 中文文档网站 (dart.cn)](https://dart.cn/)。