$toProtoBytes method

List<int> $toProtoBytes()

Implementation

List<int> $toProtoBytes() {
  var value = this;
  value = (value.abs() << 1) + (value.isNegative ? _bigOne : _bigZero);
  final nBytes = (value.bitLength - 1) ~/ 8 + 1;
  final lst = List<int>.filled(nBytes, 0, growable: false);

  for (var i = 0; i < nBytes; i++) {
    final byte = value & _fullBigByte;
    value = value >> 8;
    lst[nBytes - i - 1] = byte.toInt();
  }
  return lst;
}