Map<K, V> filterKeys<K, V>(Map<K, V> source, bool filter(K key)) => source.entries .where((e) => filter(e.key)) .toList() .asMap() .map((_, e) => e);