filterKeys method

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

Filters the map based on a condition applied to its keys.

Example:

var map = {'first': 1, 'second': 2, 'third': 3};
print(map.filterKeys((key) => key.startsWith('f'))); // Output: {'first': 1}

Implementation

Map<K, V> filterKeys(bool Function(K key) predicate) =>
    Map.fromEntries(entries.where((entry) => predicate(entry.key)));