readString method
Read a string encoded into the stream. Strings are encoded with a varuint integer length written first followed by length number of utf8 encoded bytes.
Implementation
String readString({bool explicitLength = true}) {
int length = explicitLength ? readVarUint() : buffer.lengthInBytes;
if (length == 0) {
return '';
}
Uint8List bytes =
Uint8List.view(buffer.buffer, buffer.offsetInBytes + readIndex, length);
readIndex += length;
return _utf8Decoder.convert(bytes);
}