encodeSigned static method
Converts an ordinary integer into a list of bytes that contains an LEB128 signed integer. The size of the integer is decided automatically.
Implementation
static Uint8List encodeSigned(int value) {
bool more = true;
List<int> parts = List.empty(growable: true);
while (more) {
int byte = value & 0x7f;
value >>= 7;
if (value == 0 && (byte & 0x40) == 0)
more = false;
else if (value == -1 && (byte & 0x40) > 0)
more = false;
else {
byte |= 0x80;
}
parts.add(byte);
}
return Uint8List.fromList(parts);
}