getAsList<T> method
Retrieves the element of key
of type List from Map.
If Map does not have an element of key
or the type does not match List<T>, orElse
is returned.
Implementation
List<T> getAsList<T>(K key, [List<T>? orElse]) {
assert(key != null, "The key is empty.");
if (!containsKey(key) || this[key] is! List?) {
return orElse ?? [];
}
return (this[key] as List?)?.cast<T>() ?? orElse ?? [];
}