whereValue method
Filters the map by its values using the provided predicate function.
The function f takes a value as a parameter and returns a boolean indicating
whether the value should be included in the resulting map.
Example usage:
void main() {
Map<String, int> scores = {
'John': 80,
'Alice': 90,
'Bob': 75,
'Eve': 85,
};
Map<String, int> filteredByValue = scores.whereValue((value) => value > 80);
print(filteredByValue); // Output: {Alice: 90, Eve: 85}
}
Implementation
Map<K, V> whereValue(bool Function(V value) f) => {...where((key, value) => f(value))};