Running “flutter pub get“ in flutter_app...或another command ...lock

个人认为问题根源还是墙的问题,最终是用了国内镜像解决的,虽然使用了在此之前使用了但是效果真心不好,可能还是太慢了.

在mac中open .bash_profile,将如下两条变量添加进去并保存.

之后将flutter目录中bin/lockfile文件删除并随后重启android studio.之后应该就可以正常使用pub get等命令了.

以下内容引自flutter供参考:

Using Flutter in China

The Flutter community has made a Simplified Chinese version of the Flutter website available at https://flutter.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:

  • Original URL:
    https://storage.googleapis.com/flutter_infra/releases/stable/windows/flutter_windows_v1.0.0-stable.zip

  • Mirrored URL:
    https://storage.flutter-io.cn/flutter_infra/releases/stable/windows/flutter_windows_v1.0.0-stable.zip

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

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

Configuring Flutter to use a mirror site

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.

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:

content_copy

$ 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

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.

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 [email protected] for assistance.

Community-run mirror sites

  • Shanghai Jiaotong University Linux User Group
    • FLUTTER_STORAGE_BASE_URL: https://mirrors.sjtug.sjtu.edu.cn/
    • PUB_HOSTED_URL: https://dart-pub.mirrors.sjtug.sjtu.edu.cn/

你可能感兴趣的:(flutter)