maybeParseBool static method
Parses the dynamic value
into a bool. This will return true
if and
only if the value is...
true
"true"
(case insensitive)"yes"
(case insensitive)1
When value
is null, this will return null.
Implementation
static bool? maybeParseBool(dynamic value) {
bool? result;
if (value != null) {
if (value is bool) {
result = value;
} else if (value is String) {
final lower = value.toLowerCase();
result = lower == 'true' || lower == 'yes';
} else {
result = maybeParseInt(value) == 1;
}
}
return result;
}