decode method Null safety
- Uint8List bytes
Decodes a compact size prepended Uint8List.
Implementation
static List<Uint8List> decode(Uint8List bytes) {
List<Uint8List> extractedBytes = [];
int currentSize = 0;
for (int i = 0; i < bytes.length; i += currentSize) {
currentSize = toInt(bytes.sublist(i));
if (bytes[i] <= 252) {
i++;
} else if (bytes[i] == 253) {
i += 3;
} else if (bytes[i] == 254) {
i += 5;
} else {
i += 9;
}
Uint8List currentBytes = bytes.sublist(i, i + currentSize);
extractedBytes.add(currentBytes);
}
return extractedBytes;
}