Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to StringDecoder in Dart?

Tags:

dart

I opened an old Dart project, and I get a warning about StringDecoder being undefined. How do I update my code? What do I use instead of StringDecoder ?

Example code:

response.transform(new StringDecoder()).toList().then((list) {
  print('$_client results...');
  print('${list.join()}');
  client.close();
});
like image 641
Seth Ladd Avatar asked Sep 21 '13 00:09

Seth Ladd


1 Answers

The StringEncoder and StringDecoder classes have been removed from dart:io.

Instead, import dart:convert and use the decoders of the Encodings.

Examples:

new StringDecoder() -> utf8.decoder

new StringDecoder(encoding) -> encoding.decoder

new StringEncoder() -> utf8.encoder

like image 86
Seth Ladd Avatar answered Sep 24 '22 04:09

Seth Ladd