I like the .map((item){/*mapper*/})
that is on the Iterable
classes, but the Map
class doesn't appear to implement an analogous method. When I want to do the following, I have to create an blank instance and then forEach
over the existing Map
I want to map
to the new instance type:
void noSuchMethod(Invocation inv){
if(inv.isMethod){
var namedArguments = new Map<String, dynamic>();
inv.namedArguments.forEach((k, v){
namedArguments[MirrorSystem.getName(k)] = v;
});
return;
}
super.noSuchMethod(inv);
}
Is there a nicer way of mapping Map
s? It seems a litle odd that there is a forEach((v){})
for Iterable
s and a forEach((k, v){})
for Map
s but not a map((k, v){})
for Map
s.