错误出处:
Flutter Docs--Write your first app
具体错误信息:
Running "flutter packages get" in startup_namer...
The setter 'readEventsEnabled=' was called on null.
Receiver: null
Tried calling: readEventsEnabled=false
package:pub/src/source/hosted.dart 344 BoundHostedSource._throwFriendlyError
package:pub/src/source/hosted.dart 144 BoundHostedSource.doGetVersions
===== asynchronous gap ===========================
package:pub/src/source.dart 168 BoundSource.getVersions
package:pub/src/solver/package_lister.dart 76 PackageLister._versions.<fn>.<fn>
dart:async runZoned
package:pub/src/http.dart 275 withDependencyType
package:pub/src/solver/package_lister.dart 75 PackageLister._versions.<fn>
===== asynchronous gap ===========================
dart:async new Future.sync
package:async/src/async_memoizer.dart 43 AsyncMemoizer.runOnce
package:pub/src/solver/package_lister.dart 74 PackageLister._versions
package:pub/src/solver/package_lister.dart 111 PackageLister.countVersions
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 355 VersionSolver._choosePackageVersion.<fn>
===== asynchronous gap ===========================
package:pub/src/utils.dart 309 minByAsync
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 351 VersionSolver._choosePackageVersion
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 98 VersionSolver.solve
===== asynchronous gap ===========================
package:pub/src/solver.dart 35 resolveVersions.<fn>
package:pub/src/log.dart 378 progress
package:pub/src/solver.dart 32 resolveVersions
package:pub/src/entrypoint.dart 193 Entrypoint.acquireDependencies
===== asynchronous gap ===========================
package:pub/src/command/get.dart 38 GetCommand.run
package:args/command_runner.dart 194 CommandRunner.runCommand
===== asynchronous gap ===========================
package:pub/src/command_runner.dart 168 PubCommandRunner.runCommand.<fn>
dart:async new Future.sync
package:pub/src/utils.dart 115 captureErrors.<fn>
dart:async runZoned
package:pub/src/utils.dart 134 captureErrors
package:pub/src/command_runner.dart 168 PubCommandRunner.runCommand
===== asynchronous gap ===========================
package:pub/src/command_runner.dart 117 PubCommandRunner.run
===== asynchronous gap ===========================
/b/build/slave/Mac_Engine/build/src/third_party/dart/third_party/pkg/pub/bin/pub.dart 8 main
This is an unexpected error. Please run
pub --trace --verbosity=warning get --no-precompile
and include the logs in an issue on https://github.com/dart-lang/pub/issues/new
pub get failed (1)
解决思路
1. 使用国内镜像
- 标准的国内镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
- 上海交通大学镜像
export PUB_HOSTED_URL=https://dart-pub.mirrors.sjtug.sjtu.edu.cn
export FLUTTER_STORAGE_BASE_URL=https://mirrors.sjtug.sjtu.edu.cn
2.使用终端代理
export http_proxy=http://127.0.0.1:54660
export https_proxy=http://127.0.0.1:54660
3. 偏方(用polipo建立一个http代理到socks5代理的中间转换)
docker run -d -p 8080:8123 clue/polipo proxyAddress=0.0.0.0
export http_proxy=http://127.0.0.1:8080
export https_proxy=http://127.0.0.1:8080
最后向帮助我的朋友表示感谢,也希望能帮到更多的人。
文章参考
https://github.com/flutter/flutter/wiki/Using-Flutter-in-China
https://www.jianshu.com/p/cdca06fcb828