writeVarLong method
Write a single 8 byte variable length long.
Implementation
void writeVarLong(int value, {bool signed = false}) {
if (signed || value < 0) {
if (value < 0) {
return writeVarLong(-2 * value - 1, signed: false);
} else {
return writeVarLong(2 * value, signed: false);
}
}
while (true) {
final byte = 0x7F & value;
final nextValue = value >> 7;
if (nextValue == 0) {
writeByte(byte, signed: false);
return;
}
writeByte(0x80 | byte, signed: false);
value = nextValue;
}
}