filterKeys method

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

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

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

Implementation

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