decodeLenBytes function
Implementation
int decodeLenBytes(Uint8List buf, int offset) {
if (buf[offset] < 0x80) return 1;
if (buf[offset] == 0x80) throw 'Invalid length 0';
if (buf[offset] == 0x81) return 2;
if (buf[offset] == 0x82) return 3;
if (buf[offset] == 0x83) return 4;
throw 'Length too long (> 4 bytes)';
}