readString method
Reads a string at readPosition
. It will first read
a 2 byte short for the length, then reads length-amount
of bytes and decodes them as UTF-8.
Implementation
String readString() {
var length = readShort(signed: false);
if (length == 0) return '';
var string = <int>[];
for (var i = 0; i < length; i++) {
string.add(readByte(signed: false));
}
return utf8.decode(string);
}