filterWithKey method

Map<K, V> filterWithKey(
  1. bool predicate(
    1. K key,
    2. V value
    )
)

Returns the list of those elements of the Map whose key/value satisfies predicate.

Implementation

Map<K, V> filterWithKey(bool Function(K key, V value) predicate) {
  final entries = this.entries;
  final filteredMap = <K, V>{};
  for (final item in entries) {
    if (predicate(item.key, item.value)) {
      filteredMap.addEntries([item]);
    }
  }
  return filteredMap;
}