decodeVarint static method
Decodes a varint
Implementation
static (int value, int bytesRead) decodeVarint(Uint8List bytes, [int offset = 0]) {
var value = 0;
var shift = 0;
var bytesRead = 0;
for (var i = offset; i < bytes.length; i++) {
final byte = bytes[i];
value |= (byte & 0x7F) << shift;
bytesRead++;
if (byte & 0x80 == 0) break;
shift += 7;
if (shift > 63) throw FormatException('Varint too long');
}
return (value, bytesRead);
}