stringToBool static method

bool? stringToBool(
  1. String? value
)

Converts a string to a boolean value.

Implementation

static bool? stringToBool(String? value) {
  if(TextUtils.isEmptyOrNull(value)) {
    return null;
  }
  String lowercaseValue = value!.toLowerCase().trim();
  if (lowercaseValue == "true") {
    return true;
  } else if (lowercaseValue == "false") {
    return false;
  } else {
    return null;
  }
}