I have to filter this map:
Map<int, String> example = <int,string>{
100 : 'Flutter'
200 : 'SUPERFLUTTER'
300 : 'dart'
}
The filter should only return the entries that have the filter parameter, if the filter parameter is 'dart' my filter function must return this:
Map<int, String> output = <int,string>{
300 : 'dart'
}
I'm using this function to filter:
Map<int,String> filterdMap (Map<int,String> input, String filter) {
return Map.from(input)
..removeWhere(
(key, value) => !value.toLowerCase().contains(filter),
);
}
It works, but I believe I am duplicating the map unnecessarily. Is there any other way to solve this without duplicating the map?