[0.1.1]
This commit is contained in:
15
lib/src/map_extensions.dart
Normal file
15
lib/src/map_extensions.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
Map<T, B> mergeAllMaps<T, B>(List<Map<T, B>> maps, {Function(T key, B value1, B value2)? repeatingKeysValueComparer}) {
|
||||
Map<T, B> r = <T,B>{};
|
||||
//
|
||||
for (Map<T, B> m in maps) {
|
||||
m.forEach((T key,B value) {
|
||||
if (!r.containsKey(key)) {
|
||||
r.addEntries(<MapEntry<T, B>>[MapEntry<T,B>(key, value)]);
|
||||
} else {
|
||||
repeatingKeysValueComparer?.call(key, r[key] as B, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
return r;
|
||||
}
|
||||
Reference in New Issue
Block a user