toBool method

bool? toBool()

Converts string to boolean (case-insensitive).

Accepts: "true", "yes", "1".

Implementation

bool? toBool() {
  if (this == null) return null;

  final value = this!.toLowerCase().trim();
  if (['true', 'yes', '1'].contains(value)) return true;
  if (['false', 'no', '0'].contains(value)) return false;

  return null;
}