parseBool static method

bool? parseBool(
  1. dynamic value, [
  2. bool? defaultValue
])

Implementation

static bool? parseBool(dynamic value, [bool? defaultValue]) {
  if (value is bool) {
    return value;
  } else if (value is String) {
    return value == '1' || value == 'true';
  } else if (defaultValue != null) {
    return defaultValue;
  } else {
    throw Exception('Not a boolean !');
  }
}