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