getAsMap<T> method
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にkey
の要素がない場合や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 ?? {};
}