toLittleEndianTwoBytes static method

Uint8List toLittleEndianTwoBytes(
  1. int threshold
)

Convert u16 to Uint8List of length 2 in little endian.

Implementation

static Uint8List toLittleEndianTwoBytes(int threshold) {
  if (threshold < 0 || threshold > 65535) {
    throw ArgumentError('Invalid threshold');
  }
  final arr = Uint8List(2);
  arr[0] = threshold & 0xff;
  arr[1] = threshold >> 8;
  return arr;
}