nullableDouble function
Parses a double from a JSON object, returning null if the value is null or an empty string.
jsonObject - The JSON object to parse the double from.
key - The key of the double to parse.
notNullable - Whether to return 0.0 if the value is null.
Returns a double, or null if the value is null or an empty string.
Implementation
double? nullableDouble(Map<String, dynamic> jsonObject, String key,
{bool? notNullable = false}) {
if (notNullable == true) {
return (jsonObject[key] == null) ? 0.0 : double.parse(jsonObject[key]);
}
if (jsonObject[key] == "") {
return null;
}
return (jsonObject[key] == null) ? null : double.parse(jsonObject[key]);
}