intToBool function

bool intToBool(
  1. int value
)

Converts an integer to a boolean value.

Takes an int value and returns a bool (true for 1, false for 0). Throws an ArgumentError if the value is not 0 or 1.

Implementation

bool intToBool(int value) {
  switch (value) {
    case 0:
      return false;
    case 1:
      return true;
    default:
      throw ArgumentError('Invalid bool value: $value');
  }
}