Got socket error trying to find package flutter_lints at https://pub.dev Flutter pub.dev错误的解决方案

最近想继续玩下Flutter,发现pub.dev居然被封锁了,试了下网上的方案,都不可行,尝试组合了一下,用下面的方案解决了。

第一步:

找到这个文件

D:\flutter\packages\flutter_tools\lib\src\http_host_validator.dart

把下面的地址修改为:

const String kPubDev = 'https://pub-web.flutter-io.cn/';
 
第二步:
设置系统变量

name: PUB_HOSTED_URL;
value: https://pub-web.flutter-io.cn

name: FLUTTER_STORAGE_BASE_URL;
value: https://storage.flutter-io.cn

 

运行flutter pub get 结果:

 

(base) PS D:\Project\Flutter\globaluniversity> flutter pub get
Resolving dependencies...
js 0.6.7 (0.7.1 available)
leak_tracker 10.0.0 (10.0.5 available)
leak_tracker_flutter_testing 2.0.1 (3.0.5 available)
leak_tracker_testing 2.0.1 (3.0.1 available)
material_color_utilities 0.8.0 (0.11.1 available)
meta 1.11.0 (1.14.0 available)
test_api 0.6.1 (0.7.1 available)
vm_service 13.0.0 (14.2.1 available)
Got dependencies!
8 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

 

 

posted @ 2024-04-17 13:27  商君治国安邦之张莽  阅读(632)  评论(0编辑  收藏  举报