readString method

String readString({
  1. bool explicitLength = true,
})

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;
  String value = _utf8Decoder.convert(Uint8List.view(
      buffer.buffer, buffer.offsetInBytes + readIndex, length));
  readIndex += length;
  return value;
}