writeVarUint method

void writeVarUint(
  1. int value
)

Write an integer as a list of bytes that contain an LEB128 unsigned integer. The size of the integer is decided automatically.

Implementation

void writeVarUint(int value) {
  int size = (value.toRadixString(2).length / 7.0).ceil();
  int index = 0;
  int i = 0;
  while (i < size) {
    int part = value & 0x7f;
    //ignore: parameter_assignments
    value >>= 7;
    _variableEncodeList[index++] = part;
    i += 1;
  }
  for (var i = 0; i < index - 1; i++) {
    _variableEncodeList[i] |= 0x80;
  }
  write(_variableEncodeList, index);
}