Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
164 lines (115 sloc) 6.64 KB
title description toc
在中国网络环境下使用 Flutter
如果你需要在中国网络环境下使用 Flutter,请查阅此页面。
true

{% assign path = 'flutter_infra/releases/stable/windows/flutter_windows_v1.0.0-stable.zip' -%}

The Flutter community has made a Simplified Chinese version of the Flutter site website available at https://flutter-io.cn.

欢迎你来到由中国 Flutter 社区维护的中文 Flutter 资源网站:https://flutter-io.cn

If you’d like to install Flutter using an installation bundle, you can replace the domain of the original URL with a trusted mirror to speed it up. For example:

如果你需要下载 Flutter SDK 的独立打包文件,你可以将下载链接前缀替换为你信任的镜像链接。

You must also set two environment variables to upgrade Flutter and use the pub package repository in China. Instructions are below.

同时为了正常升级 Flutter 和通过 pub package 命令获取 packages,你需要设置如下两个环境变量, 设置方式如下:

{{site.alert.important}}

Use mirror sites only if you trust the provider. The Flutter team cannot verify their reliability or security.

使用任意镜像网站的时候,你必须确保你 信任 你的镜像提供者。 Flutter 团队无法确保他们的安全性。

{{site.alert.end}}

Configuring Flutter to use a mirror site

为 Flutter 设定镜像配置

If you’re installing or using Flutter in China, it may be helpful to use a trustworthy local mirror site that hosts Flutter’s dependencies. To instruct the Flutter tool to use an alternate storage location, you need to set two environment variables, PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL, before running the flutter command.

如果你在国内使用 Flutter,那么你可能需要找一个与官方同步的可信的镜像站点, 帮助你的 Flutter 命令行工具到该镜像站点下载其所需的资源。 你需要为此设置两个环境变量:“PUB_HOSTED_URL”和“FLUTTER_STORAGE_BASE_URL”, 然后再运行 Flutter 命令行工具。

Taking MacOS or Linux as an example, here are the first few steps in the setup process for using a mirror site. Run the following in a Bash shell from the directory where you wish to store your local Flutter clone:

以 macOS 或者与 Linux 相近的系统为例,这里有以下步骤帮助你设定镜像。 在系统终端里执行如下命令设定环境变量,并通过 GitHub 检出 Flutter SDK:

$ export PUB_HOSTED_URL=https://pub.flutter-io.cn
$ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
$ git clone -b dev {{site.github}}/flutter/flutter.git
$ export PATH="$PWD/flutter/bin:$PATH"
$ cd ./flutter
$ flutter doctor

After these steps, you should be able to continue setting up Flutter normally. From here on, packages fetched by flutter pub get are downloaded from flutter-io.cn in any shell where PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL are set.

如上步骤设定之后,你可以继续进行 Flutter 安装的下一步:编辑工具设定, 在这两个环境变量(PUB_HOSTED_URLFLUTTER_STORAGE_BASE_URL)设定过后, 未来通过命令 flutter pub get 获取 packages 的时候,网络请求将会通过 flutter-io.cn 提供的镜像进行。

The flutter-io.cn server is a provisional mirror for Flutter dependencies and packages maintained by GDG China. The Flutter team cannot guarantee long-term availability of this service. You’re free to use other mirrors if they become available. If you’re interested in setting up your own mirror in China, contact flutter-dev@googlegroups.com for assistance.

flutter-io.cn 所提供的镜像由中国的 Flutter 开发者社区提供和维护, Flutter 团队无法保证其的长期稳定运作,你也可以自由使用其他可信的机构提供的镜像服务。 如果你想在中国设定自己的镜像,请与通过邮件群组获得帮助:flutter-dev@googlegroups.com

Community-run mirror sites

社区运行的镜像站点

如下列表为目前在国内提供镜像的社区, 由于镜像的实现方式有所不同,可能回导致数据的滞后等问题。 我们制作了一个 镜像可用性监控页面,供参考。

Flutter 社区

社区主镜像,采用多种方式同步 Flutter 开发者资源。

$ export PUB_HOSTED_URL=https://pub.flutter-io.cn
$ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

上海交大 Linux 用户组

Pub API 返回值(archive_url)需要优化,可能造成无法访问的情况。

$ export PUB_HOSTED_URL=https://dart-pub.mirrors.sjtug.sjtu.edu.cn
$ export FLUTTER_STORAGE_BASE_URL=https://mirrors.sjtug.sjtu.edu.cn

清华大学 TUNA 协会

(推荐)定时与 Flutter 社区 Storage 镜像同步,Pub API 采取定时主动抓取策略,数据可能有延迟,已知的延迟见页面最下方。 目前正在尝试进行 404 数据(延迟数据)回源(Flutter 社区镜像站)策略。

$ export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter

CNNIC

基于 TUNA 协会的镜像服务,数据策略与 TUNA 一致,通过非教育网的域名访问。

$ export PUB_HOSTED_URL=http://mirrors.cnnic.cn/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=http://mirrors.cnnic.cn/flutter

腾讯云开源镜像站

定时(每天凌晨)与 TUNA 协会镜像同步,数据有延迟,访问速度有待反馈。

$ export PUB_HOSTED_URL=https://mirrors.cloud.tencent.com/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=https://mirrors.cloud.tencent.com/flutter

已知问题

  • 上海交大 Linux 用户组镜像的 Pub API 返回值(archive_url)需要优化, 可能造成 Packages 无法下载的情况。

  • TUNA 协会镜像有一台负载均衡的服务器数据同步延迟(最新数据是 5/22),已经在解决。

  • 上海大学的镜像暂时只允许校内访问。

You can’t perform that action at this time.