toBoolNullable method

bool? toBoolNullable()

Converts a case-insensitive string of 'true' or 'false' to a boolean. Returns null if the string is empty or not 'true' or 'false'.

Implementation

bool? toBoolNullable() {
  if (toLowerCase() == 'true') {
    return true;
  } else if (toLowerCase() == 'false') {
    return false;
  }
  return null;
}