readVarUint method

int readVarUint()

Reads a variable-length unsigned integer. Compatible with Protocol Buffers encoding.

Implementation

int readVarUint() {
  final byteData = this._byteData;
  final start = this.index;
  var index = start;
  var result = 0;
  for (var i = 0; i < 64; i += 7) {
    if (index >= byteData.lengthInBytes) {
      throw _eofException(index, "VarUint");
    }
    final byte = byteData.getUint8(index);
    index++;
    result |= (0x7F & byte) << i;
    if (0x80 & byte == 0) {
      break;
    }
  }
  this.index = index;
  return result;
}