parseBool static method

bool? parseBool(
  1. Object? raw
)

Implementation

static bool? parseBool(Object? raw) {
  if (raw is bool) return raw;
  if (raw is num) {
    if (raw == 0) return false;
    if (raw == 1) return true;
    return null;
  }
  if (raw is String) {
    switch (raw.trim().toLowerCase()) {
      case 'true':
      case 'yes':
      case '1':
        return true;
      case 'false':
      case 'no':
      case '0':
        return false;
    }
  }
  return null;
}