intToBytes method

List<int> intToBytes(
  1. int value
)

Converts a 64-bit integer to a little-endian byte array.

Takes an integer value and creates a ByteData object with an 8-byte capacity, then sets the 64-bit integer value into the ByteData object using little-endian byte order. Finally, it converts the ByteData buffer to a Uint8List to obtain the byte array.

Parameters:

  • value: The 64-bit integer to be converted.

Returns: A List<int> representing the little-endian byte array.

Implementation

List<int> intToBytes(int value) {
  ByteData byteData = ByteData(8); // 8 bytes for a 64-bit integer
  byteData.setInt64(
      0, value, Endian.little); // Assuming little-endian byte order
  return byteData.buffer.asUint8List();
}