asInt method

int asInt(
  1. String key, {
  2. int def = 0,
})

Retrieves the integer value associated with the key. If the key does not exist or the value cannot be parsed as an integer, 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 integer value associated with the key or def if not found or cannot be parsed.

Implementation

int asInt(String key, {int def = 0}) {
  if (keys.contains(key)) {
    return this[key].asInt(def: def);
  }

  return def;
}