问题
我从 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>'
一些额外的细节
- Flutter 提交
4cd12fc8b
- 之前它运行良好。
最佳答案
此实现在修复流处理中的错误后发生更改。
以下是Flutter社区提出的变更请求- https://github.com/dart-lang/sdk/issues/36900
您可以通过以下更改解决此问题
request.close().then((response){
response.cast<List<int>>().transform(utf8.decoder).listen((content) {
return content;
});
});
关于监听数据时出现 HttpClientResponse 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56862020/