toBool function

bool? toBool(
  1. dynamic s
)

Implementation

bool? toBool(dynamic s) {
  try {
    if (s == null) return null;
    if (s is bool) return s;
    s = s.toString().trim().toLowerCase();
    if (s == "true") return true;
    if (s == "false") return false;
    return null;
  } catch (e) {
    return null;
  }
}