【问题标题】:HttpClientResponse Error while Listen Data监听数据时出现 HttpClientResponse 错误
【发布时间】:2019-07-03 02:09:20
【问题描述】:

问题

我收到来自HttpClientResponse 的回复,然后尝试执行如下监听:

//... your code
response.transform(utf8.decoder).listen( (data) {
   //... your code
})
//... your code

错误

The argument type 'Utf8Decoder' can't be assigned to the parameter type 'StreamTransformer<Uint8List, dynamic>'

一些额外的细节

  • 颤振提交4cd12fc8b
  • 之前它运行良好。

【问题讨论】:

    标签: http flutter dart httpclient


    【解决方案1】:

    在修复 Stream 处理中的错误后更改了此实现。

    以下是 Flutter 社区提出的更改请求 - https://github.com/dart-lang/sdk/issues/36900

    您可以通过以下更改解决此问题

    request.close().then((response){
      response.cast<List<int>>().transform(utf8.decoder).listen((content) {
            return content;
          });
    });
    

    供参考:https://github.com/dart-lang/co19/pull/384

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-24
      • 2020-07-30
      • 2013-12-26
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多