getAsInt method

int getAsInt(
  1. K key, [
  2. int orElse = 0

Retrieves the element of key of type int from Map.

If Map does not have an element of key or the type does not match int, orElse is returned.




int getAsInt(K key, [int orElse = 0]) {
  assert(key != null, "The key is empty.");
  if (!containsKey(key) || this[key] is! num?) {
    return orElse;
  return (this[key] as num?)?.toInt() ?? orElse;