readString method

String readString()

Decodes a UTF-8 string with length prefix

Format: u32 length + UTF-8 bytes

Example:

final text = decoder.readString();

Implementation

String readString() {
  final length = readU32();
  _checkRemaining(length);

  final bytes = _bytes.sublist(_offset, _offset + length);
  _offset += length;

  return utf8.decode(bytes);
}