toBool static method
Returns a bool from a String if it is a bool value including '0' / '1' / 'no' / 'yes'
Implementation
static bool? toBool(dynamic s)
{
try
{
if (s == null) return null;
if (s is bool) return s;
String b = s.toString();
b = b.trim().toLowerCase();
if ((b == 'false') || (b == '0') || (b == 'no')) return false;
if ((b == 'true') || (b == '1') || (b == 'yes')) return true;
return null;
}
catch(e)
{
return null;
}
}