toBigEndianArray function

Uint8List toBigEndianArray(
  1. int n
)

Converts a 32-bit unsigned integer to a big endian byte array.

Implementation

Uint8List toBigEndianArray(int n) {
  final byteArray = Uint8List.fromList([0, 0, 0, 0]);
  for (int i = byteArray.length - 1; i >= 0; i--) {
    final byte = n & 0xff;
    byteArray[i] = byte;
    n = ((n - byte) ~/ 256).toInt();
  }
  return byteArray;
}