getAsMap<T> method

Map<String, T> getAsMap<T>(
  1. K key, [
  2. Map<String, T>? orElse
])

Retrieves the element of key of type Map from Map.

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

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

Mapkeyの要素がない場合やMap<String, T>と型が合わない場合、自身がNullの場合はorElseが返されます。

Implementation

Map<String, T> getAsMap<T>(K key, [Map<String, T>? orElse]) {
  assert(key != null, "The key is empty.");
  if (this == null || !containsKey(key) || this![key] is! Map?) {
    return orElse ?? {};
  }
  return (this![key] as Map?)?.cast<String, T>() ?? orElse ?? {};
}