where method

Map<K, V> where(
  1. KeyValuePredicate<K, V> p
)

Returns a new Map by filtering its entries using the given predicate.

Implementation

Map<K, V> where(KeyValuePredicate<K, V> p) {
  Map<K, V> map = {};

  forEach((k, v) {
    if (p(k, v)) map[k] = v;
  });

  return map;
}