toBinaryBool static method

List<bool> toBinaryBool(
  1. int value, {
  2. int? bitLength,
})

Implementation

static List<bool> toBinaryBool(int value, {int? bitLength}) {
  bitLength ??= bitlengthInBytes(value) * 8;
  // Make sure we have exactly 64 bits
  final bits = List<bool>.filled(bitLength, false);

  for (int i = 0; i < bitLength; i++) {
    // Check if the i-th bit is set
    bits[i] = value & (1 << i) != 0;
  }
  return bits;
}