readAsString method
Returns a Future containing the body as a String.
If encoding
is passed, that's used to decode the body.
Otherwise the encoding is taken from the Content-Type header. If that
doesn't exist or doesn't have a "charset" parameter, UTF-8 is used.
This calls read
internally, which can only be called once.
Implementation
Future<String> readAsString([Encoding? encoding]) {
encoding ??= this.encoding ?? utf8;
return encoding.decodeStream(read());
}