flutter web http.get 返回“不支持的操作:Platform._version”

use*_*095 8 flutter

我正在开发 flutter web 应用程序并尝试从互联网上获取一些数据我正在使用 package:http/http.dart 并尝试这样做:

await http.get(url);
Run Code Online (Sandbox Code Playgroud)

但我收到了这个错误:

不支持的操作:Platform._version

daz@daz:/rom/source/public/checkout_example$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel master, v1.16.2-pre.41, on Linux, locale en_US.UTF-8)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[?] Chrome - develop for the web
[?] Linux toolchain - develop for Linux desktop
[?] Android Studio (version 3.6)
[!] IntelliJ IDEA Community Edition (version 2019.3)
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
[?] Connected device (3 available)

! Doctor found issues in 2 categories.
Run Code Online (Sandbox Code Playgroud)

小智 3

我相信你现在已经明白了这一点,但我也遇到了同样的问题并看到了这篇文章。

因此,现在已经找到了解决方案,我想我会将其发布在这里,以拯救下一个遇到它的人。

解决办法是更新插件http版本pubspec.yaml

我一直在使用http: "0.11.3+17"并收到该错误。

我将条目更新pubspec.yamlhttp: ^0.12.1并且它有效。