To speed the download and installation of Flutter in China, consider using a mirror site or mirror.

Use a Flutter mirror site

#

The China Flutter User Group (CFUG) maintains a Simplified Chinese Flutter website https://flutter.cn and a mirror. Other mirrors can be found at the end of this guide.

Configure your machine to use a mirror site

#

To install or use Flutter in China, use a trustworthy Flutter mirror. This requires setting two environment variables on your machine.

All examples that follow presume that you are using the CFUG mirror.

To set your machine to use a mirror site:

These steps require using PowerShell.

  1. Open a new window in PowerShell to prepare to run shell commands.

  2. Set PUB_HOSTED_URL to your mirror site.

    $env:PUB_HOSTED_URL="https://pub.flutter-io.cn"
  3. Set FLUTTER_STORAGE_BASE_URL to your mirror site.

    $env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
  4. Download the Flutter archive from your preferred mirror site.

    For CFUG, visit their Flutter SDK archive, and download the SDK for your platform and architecture.

  5. Create a folder where you can install Flutter. Then change into it. Consider a path like $env:USERPROFILE\dev.

    New-Item -Path "$env:USERPROFILE\dev" -ItemType Directory; cd "$env:USERPROFILE\dev"
  6. Extract the SDK from the zip archive file.

    This example assumes you downloaded the Windows version of the Flutter SDK. You'll need to replace the path to the archive with the path to the archive file and version you downloaded.

    Expand-Archive .\flutter_windows_3.35.5-stable.zip
  7. Add Flutter to your PATH environment variable.

    $env:PATH = $pwd.PATH + "\flutter\bin",$env:PATH -join ";"
  8. Begin developing with Flutter.

    After following these steps, Flutter fetches packages and artifacts from flutter-io.cn in the current terminal window.

    To set these values permanently across terminals, follow the instructions on adding Flutter to your PATH, also adding the PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL variables.

  1. Open a new window in your terminal to prepare to run shell commands.

  2. Set PUB_HOSTED_URL to your mirror site.

    export PUB_HOSTED_URL="https://pub.flutter-io.cn"
  3. Set FLUTTER_STORAGE_BASE_URL to your mirror site.

    export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
  4. Download the Flutter archive from your preferred mirror site.

    For CFUG, visit their Flutter SDK archive, and download the SDK for your platform and architecture.

  5. Create a folder where you can install Flutter. Then change into it. Consider a path like ~/dev.

    mkdir ~/dev; cd ~/dev
  6. Extract the SDK from the zip archive file.

    This example assumes you downloaded the macOS version of the Flutter SDK. You'll need to replace the path to the archive with the path to the archive file and version you downloaded.

    unzip flutter_macos_3.35.5-stable.zip
  7. Add Flutter to your PATH environment variable.

    export PATH="$PWD/flutter/bin:$PATH"
  8. Begin developing with Flutter.

    After following these steps, Flutter fetches packages and artifacts from flutter-io.cn in the current terminal window.

    To set these values permanently across terminals, follow the instructions on adding Flutter to your PATH, also adding the PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL variables.

  1. Open a new window in your terminal to prepare to run shell commands.

  2. Set PUB_HOSTED_URL to your mirror site.

    export PUB_HOSTED_URL="https://pub.flutter-io.cn"
  3. Set FLUTTER_STORAGE_BASE_URL to your mirror site.

    export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
  4. Download the Flutter archive from your preferred mirror site.

    For CFUG, visit their Flutter SDK archive, and download the SDK for your platform and architecture.

  5. Create a folder where you can install Flutter. Then change into it. Consider a path like ~/dev.

    mkdir ~/dev; cd ~/dev
  6. Extract the SDK from the tar archive file.

    This example assumes you downloaded the Linux version of the Flutter SDK. You'll need to replace the path to the archive with the path to the archive file and version you downloaded.

    tar -xf flutter_linux_3.35.5-stable.tar.xz
  7. Add Flutter to your PATH environment variable.

    export PATH="$PWD/flutter/bin:$PATH"
  8. Begin developing with Flutter.

    After following these steps, Flutter fetches packages and artifacts from flutter-io.cn in the current terminal window.

    To set these values permanently across terminals, follow the instructions on adding Flutter to your PATH, also adding the PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL variables.

Download Flutter archives based on a mirror site

#

To download Flutter from the SDK archive from a mirror, replace storage.googleapis.com with the URL of your trusted mirror. Use your mirror site in the browser or in other applications like IDM or Thunder. This should improve download speed.

The following example shows how to change the URL for Flutter's download site from Google's archive to CFUG's mirror.

To download the x64, Windows version of the Flutter SDK, you would change the original URL from:

https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.35.5-stable.zip

to the mirror URL:

https://storage.flutter-io.cn/flutter_infra_release/releases/stable/windows/flutter_windows_3.35.5-stable.zip

To download the arm64, macOS version of the Flutter SDK, you would change the original URL from:

https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_3.35.5-stable.zip

to the mirror URL:

https://storage.flutter-io.cn/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_3.35.5-stable.zip

To download the Linux version of the Flutter SDK, you would change the original URL from:

https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.35.5-stable.tar.xz

to the mirror URL:

https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_3.35.5-stable.tar.xz

Configure your machine to publish your package

#

To publish your packages to pub.dev, you need to be able to access both Google Auth and the pub.dev site.

To enable access to pub.dev:

  1. Configure a proxy. To configure a proxy, check out the Dart documentation on proxies.

  2. Verify that your PUB_HOSTED_URL environment variable is either unset or empty.

    echo $env:PUB_HOSTED_URL

    If this command returns any value, unset it.

    Remove-Item $env:PUB_HOSTED_URL
  1. Configure a proxy. To configure a proxy, check out the Dart documentation on proxies.

  2. Verify that your PUB_HOSTED_URL environment variable is either unset or empty.

    echo $PUB_HOSTED_URL

    If this command returns any value, unset it.

    unset $PUB_HOSTED_URL
  1. Configure a proxy. To configure a proxy, check out the Dart documentation on proxies.

  2. Verify that your PUB_HOSTED_URL environment variable is either unset or empty.

    echo $PUB_HOSTED_URL

    If this command returns any value, unset it.

    unset $PUB_HOSTED_URL

To learn more about publishing packages, check out the Dart documentation on publishing packages.

Known, trusted community-run mirror sites

#

The Flutter team can't guarantee the long-term availability of any mirrors. You can use other mirrors if they become available.


China Flutter User Group

#

China Flutter User Group maintains the flutter-io.cn mirror. It includes the Flutter SDK and pub packages.

Configure your machine to use this mirror

#

To set your machine to use this mirror, use these commands.

On macOS, Linux, or ChromeOS:

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

On Windows:

$env:PUB_HOSTED_URL="https://pub.flutter-io.cn";
$env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"

Get support for this mirror

#

If you're running into issues that only occur when using the flutter-io.cn mirror, report the issue to their issue tracker.


Shanghai Jiao Tong University *nix User Group

#

Shanghai Jiao Tong University *nix User Group maintains the mirror.sjtu.edu.cn mirror. It includes the Flutter SDK and pub packages.

Configure your machine to use this mirror

#

To set your machine to use this mirror, use these commands.

On macOS, Linux, or ChromeOS:

export PUB_HOSTED_URL=https://mirror.sjtu.edu.cn/dart-pub;
export FLUTTER_STORAGE_BASE_URL=https://mirror.sjtu.edu.cn

On Windows:

$env:PUB_HOSTED_URL="https://mirror.sjtu.edu.cn/dart-pub";
$env:FLUTTER_STORAGE_BASE_URL="https://mirror.sjtu.edu.cn"

Get support for this mirror

#

If you're running into issues that only occur when using the mirror.sjtu.edu.cn mirror, report the issue to their issue tracker.


Tsinghua University TUNA Association

#

Tsinghua University TUNA Association maintains the mirrors.tuna.tsinghua.edu.cn mirror. It includes the Flutter SDK and pub packages.

Configure your machine to use this mirror

#

To set your machine to use this mirror, use these commands.

On macOS, Linux, or ChromeOS:

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

On Windows:

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

Get support for this mirror

#

If you're running into issues that only occur when using the mirrors.tuna.tsinghua.edu.cn mirror, report the issue to their issue tracker.

Offer to host a new mirror site

#

If you're interested in setting up your own mirror, contact flutter-dev@googlegroups.com for assistance.