我正在开发颤振网络应用程序,并试图从互联网上获取一些数据,我使用的包是:http/http.dart,并尝试这样做:
await http.get(url);但我发现了一个错误:
不支持的操作: 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.发布于 2020-05-09 13:25:10
我相信你现在已经弄明白了,但我只是遇到了同样的问题,并偶然发现了这篇文章。
所以,现在想出了解决方案,我想我会在这里发布它,以挽救下一个遇到它的人。
解决方案是更新http插件在pubspec.yaml中的版本。
我一直在使用http: "0.11.3+17",并得到了这个错误。
我将pubspec.yaml中的条目更新为http: ^0.12.1,它可以工作。
发布于 2021-07-05 16:31:24
我遇到的问题是,我显式地使用了IOClient,浏览器不支持它;在这种情况下需要使用BrowserClient (这是使用http v0.13.3)。
解决办法:
var client = http.Client();根据平台创建正确的平台。
来自Client()文档:
如果
可用,则创建
IOClient,如果dart:html可用,则创建BrowserClient,否则将引发不受支持的错误。
https://stackoverflow.com/questions/59952087
复制相似问题