convertToString function

Future<String> convertToString(
  1. HttpClientResponse response
)

Implementation

Future<String> convertToString(HttpClientResponse response) {
  var completer = Completer<String>();
  var contents = StringBuffer();
  response.transform(utf8.decoder).listen((String data) {
    contents.write(data);
  }, onDone: () => completer.complete(contents.toString()));
  return completer.future;
}