length static method

List<int> length(
  1. int value
)

Implementation

static List<int> length(int value) {
  if (value < 0x80) return <int>[value];
  final List<int> bytes = <int>[];
  int remaining = value;
  while (remaining > 0) {
    bytes.insert(0, remaining & 0xff);
    remaining >>= 8;
  }
  return <int>[0x80 | bytes.length, ...bytes];
}