parseBool function
Parses a string into a bool.
- Accepts
"true"or"false"(case‑insensitive). - Returns
nullifvalueisnullor empty. - Throws Exception if the string is not valid.
Implementation
bool? parseBool(String? value) {
if (value != null && value.isNotEmpty) {
switch (value.toLowerCase()) {
case "true":
return true;
case "false":
return false;
default:
throw Exception("Problem parsing bool value: $value");
}
}
return null;
}