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 does not have an element of key or the type does not match Map<String, T>, orElse is returned.


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


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