Flutter web Http GET抛出未等待的函数

rkkpypqq  于 2023-06-24  发布在  Flutter
关注(0)|答案(1)|浏览(143)

我使用flutter为web运行一个HTTPget,连接后它停止运行,并将我定向到browser_client.dart文件,突出显示此函数

unawaited(xhr.onLoad.first.then((_) {
  var body = (xhr.response as ByteBuffer).asUint8List();
  completer.complete(StreamedResponse(
      ByteStream.fromBytes(body), xhr.status!,
      contentLength: body.length,
      request: request,
      headers: xhr.responseHeaders,
      reasonPhrase: xhr.statusText));
}));

然后在调试控制台上显示

Error: error
    at Object.throw_ [as throw] (http://localhost:53840/dart_sdk.js:5061:11)
at searchListing (http://localhost:53840/packages/maimo/app/data/services/api.dart.lib.js:33:19)
    at searchListing.next (<anonymous>)
    at http://localhost:53840/dart_sdk.js:38640:33
    at _RootZone.runUnary (http://localhost:53840/dart_sdk.js:38511:59)
    at _FutureListener.thenAwait.handleValue (http://localhost:53840/dart_sdk.js:33713:29)
    at handleValueCallback (http://localhost:53840/dart_sdk.js:34265:49)
col17t5w

col17t5w1#

尝试降级pubspec.yaml中的http包。在我的情况下,我被降级到^0.13.5版本。在我的案例中解决了这个步骤

相关问题