where method

Map<K, V> where(
  1. bool f(
    1. K key,
    2. V value
    )
)

Allows us to find an entry based on key and value

Example:

people.where((key, value) => key.length > 4 && value > 20);
// {Peter: 22}

const Map<String, int> people = {'John': 20, 'Mary': 21, 'Peter':20};

Implementation

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