企业防火墙后面的 Flutter 应用程序在包获取期间抛出 TLS 错误

Man*_*hah 6 proxy dart flutter flutter-dependencies

最近安装了 Flutter 并探索了 hello-world 应用程序。遵循https://flutter.io/get-started/ 中提到的所有步骤并能够运行

:: 颤振医生

Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel beta, v0.5.1, on Microsoft Windows [Version 10.0.15063], locale en-US)
[?] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[?] Android Studio (version 3.1)
[!] VS Code, 64-bit edition (version 1.26.0)
[?] Connected devices (1 available)
! Doctor found issues in 1 categories.
Run Code Online (Sandbox Code Playgroud)

还可以使用以下命令创建应用程序框架;

:: 颤动创建我的应用程序

但是当它尝试安装 pubspec.yaml 下提到的所有依赖项时,它开始显示错误并继续尝试重新连接。这是日志,

Running "flutter packages get" in hello_world...
Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
pub get failed (69) -- attempting retry 1 in 1 second...
Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
pub get failed (69) -- attempting retry 2 in 2 seconds...
Run Code Online (Sandbox Code Playgroud)

我怀疑是因为防火墙和其他包管理器,我一直在使用代理服务器来启用 fetch 工作得很好。我找不到一种方法来为 flutter 或 pub 实现这样的代理。我也尝试使用中国服务器,但这也没有帮助我。我已经安装和卸载了几次以确保缓存不会导致此问题。

有没有人想过这个?

use*_*190 4

我遇到过同样的问题。我在一家公司工作,我必须使用 https_proxy 环境变量来获取连接。

在 Windows 上打开 cmd

设置 https_proxy=用户名:密码@主机名:端口

颤动创建

扑腾跑

颤振包获取

这对我有用,希望有帮助!