filterValues method

Map<K, V> filterValues(
  1. bool predicate(
    1. V
    )
)

Returns a map containing all key-value pairs with values matching the given predicate.

The returned map preserves the entry iteration order of the original map.

Implementation

Map<K, V> filterValues(bool Function(V) predicate) {
  final result = <K, V>{};
  for (final entry in entries) {
    if (predicate(entry.value)) {
      result[entry.key] = entry.value;
    }
  }
  return result;
}