where method

Map<K, V> where(
  1. bool func(
    1. MapEntry<K, V> mapEntry
    )
)

Works like List.where, you put in a function that takes a MapEntry and returns a bool. This will return new Map where the above function is true.

Implementation

Map<K, V> where(bool Function(MapEntry<K, V> mapEntry) func) {
  Map<K, V> newMap = {};
  for (MapEntry<K, V> entry in entries) {
    if (func(entry)) {
      newMap[entry.key] = entry.value;
    }
  }
  return newMap;
}