1. Install the method of Flutter slow

The official of Flutter has given a method that can be used happily in China – the Chinese mirror of Flutter

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
git clone -b dev https://github.com/flutter/flutter.git
export PATH="$PWD/flutter/bin:$PATH"
cd ./flutter
flutter doctor
Copy the code

2. Solution to slow installation of third-party packages

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
flutter packages get
Copy the code

The above export is a temporary environment variable, which can be added to ~/.bash_profile once and for all

export PATH=xxx/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Copy the code

After adding, use source ~/.bash_profile to update the newly configured environment variable. XXX is the installation path of Flutter.

Waiting for another flutter command to release the startup lock

Delete the /bin/cache/lockfile file of flutter installation directory and restart the development tool.