encodeTo method
Convert self to a slice and append it to the destination.
Implementation
@override
void encodeTo(int value, Output output) {
if (value < 64) {
output.pushByte(value.toInt() << 2);
} else if (value < 16384) {
output
..pushByte((value.toInt() & 0x3F) << 2 | 1)
..pushByte((value.toInt() >> 6).toUnsigned(8));
} else if (value < 1073741824) {
output
..pushByte((value.toInt() & 0x3F) << 2 | 2)
..pushByte((value.toInt() >> 6).toUnsigned(8))
..pushByte((value.toInt() >> 14).toUnsigned(8))
..pushByte((value.toInt() >> 22).toUnsigned(8));
} else {
assertion(value.bitLength >= 30,
'Previously checked anyting less than 2^30; qed');
final bytesNeeded = (value.bitLength + 7) >> 3;
output.pushByte(((bytesNeeded - 4) << 2).toUnsigned(8) | 3);
for (var i = 0; i < bytesNeeded; i++) {
output.pushByte(value.toUnsigned(8).toInt());
value >>= 8;
}
assertion(value == 0, 'Value is not fully consumed; qed');
}
}