getAsSet<T> method

Set<T> getAsSet<T>(
  1. K key, [
  2. Set<T>? orElse
])

Retrieves the element of key of type Set from Map.

If Map does not have an element of key or the type does not match Set<T>, orElse is returned.

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

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

Implementation

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