HttpClientResponse Error while Listen Data

2019-07-24 04:50发布

Problem

I get response from HttpClientResponse After that trying to perform listen like:

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

Error(s)

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

Some Extra Detail(s)

  • Flutter Commit at 4cd12fc8b
  • Previously it was working fine.

1条回答
迷人小祖宗
2楼-- · 2019-07-24 05:24

This implementation is changed after fixing a bug in Stream handling.

Following is the changed request raised in Flutter community - https://github.com/dart-lang/sdk/issues/36900

You can fix this issue with following changes

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

For reference : https://github.com/dart-lang/co19/pull/384

查看更多
登录 后发表回答