asDouble method

double asDouble(
  1. String key, {
  2. double def = 0,
})

Retrieves the double value associated with the key. If the key does not exist or the value cannot be parsed as a double, returns the def value.

key The key in the map to retrieve the value from. def The default value to return if the key is not found or the value cannot be parsed. Defaults to 0.

Returns: The double value associated with the key or def if not found or cannot be parsed.

Implementation

double asDouble(String key, {double def = 0}) {
  if (keys.contains(key)) {
    return double.tryParse(this[key].toString()) ?? def;
  }

  return def;
}