getAsInt method

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

Retrieves the element of key of type int from Map.

If Map has no element of key, or if the type does not match int, or if Map is itself Null, orElse is returned.

Mapからint型のkeyの要素を取得します。

Mapkeyの要素がない場合やintと型が合わない場合、自身がNullの場合はorElseが返されます。

Implementation

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