intToBigEndianBytes static method

Uint8List intToBigEndianBytes(
  1. int value, {
  2. int length = 8,
})

Return a Uint8List of big endian bytes representing an integer.

Implementation

static Uint8List intToBigEndianBytes(
  final int value, {
  final int length = 8,
}) {
  final Uint8List result = Uint8List(length);
  for (int i = 0; i < length; i++) {
    result[length - 1 - i] = (value >> (8 * i)) & 0xff;
  }
  return result;
}