tryBoolify static method
Returns the truthy value of value
(refer to EZ.boolify for details)
or null, if the truthy value cannot be figured out (i.e. instead of
throwing an exception like EZ.boolify does).
Implementation
static bool? tryBoolify(dynamic value) {
if (value == null) {
return false;
}
if (value is bool) {
return value;
}
if (value is String) {
if (value == "" || value == "0" || value.toLowerCase() == "false") {
return false;
}
return true;
}
if (value is num) {
return (value != 0);
}
return null;
}