Reputation: 6786
If I have a list of key/value pairs, how would I convert them to a single map?
eg [{'ore': 'value'}, {'pure':'value'}, {'steel':'value}]. =>
{'ore': 'value',
'pure':'value'
'steel':'value'}
Upvotes: 0
Views: 1022
Reputation: 71853
Just build a new map containing all the individual map's entries:
List<Map<Something, Other>> listOfMaps = ...;
var combinedMap = {for (var map in listOfMaps) ...map};
Upvotes: 5
Reputation: 4249
Use the reduce function
var v =[{'ore': 'value'}, {'pure':'value'}, {'steel':'value'}];
var w = v.reduce((a,b){
a.addAll(b);
return a;
});
Upvotes: 3