From b780647445808019d5632bb9dcebffc6158a3878 Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Mon, 3 Mar 2025 16:15:12 +0200 Subject: [PATCH] [0.1.1] --- .dart_tool/package_config.json | 2 +- README.md | 2 +- lib/src/map_extensions.dart | 32 ++++++++++++++++++-------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 5f4c2c5..e5451b7 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -62,7 +62,7 @@ "languageVersion": "3.6" } ], - "generated": "2025-03-03T14:08:32.247456Z", + "generated": "2025-03-03T14:15:05.778488Z", "generator": "pub", "generatorVersion": "3.7.0", "flutterRoot": "file:///C:/Users/micwa/fvm/versions/stable", diff --git a/README.md b/README.md index e6a1ed9..d673e64 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Developed, Maintained, and is property of Michael W. Aziz (Micazi) - on _List_ - **containsAll()** : Checker to see if a list contains all of the other list. ☑️ - **getUnique()** : Get unique items only of a supplied list. ☑️ -- on _Map_ +- on _List>_ - **mergeAllMaps()** : Merges a list of maps into one with a conditional functionality to approve the merge. ☑️ - on _TextAlignVertical_ - **toAlignment()** : convert a `TextAlignVertical` to an `Alignment` object. ☑️ diff --git a/lib/src/map_extensions.dart b/lib/src/map_extensions.dart index de3cbf2..929f348 100644 --- a/lib/src/map_extensions.dart +++ b/lib/src/map_extensions.dart @@ -1,15 +1,19 @@ -Map mergeAllMaps(List> maps, {Function(T key, B value1, B value2)? repeatingKeysValueComparer}) { - Map r = {}; - // - for (Map m in maps) { - m.forEach((T key,B value) { - if (!r.containsKey(key)) { - r.addEntries(>[MapEntry(key, value)]); - } else { - repeatingKeysValueComparer?.call(key, r[key] as B, value); - } - }); +extension MapExtensions on Map {} + +extension MapListExtensions on List> { + Map mergeAllMaps({Function(T key, B value1, B value2)? repeatingKeysValueComparer}) { + Map r = {}; + // + for (Map m in this) { + m.forEach((T key, B value) { + if (!r.containsKey(key)) { + r.addEntries(>[MapEntry(key, value)]); + } else { + repeatingKeysValueComparer?.call(key, r[key] as B, value); + } + }); + } + // + return r; } - // - return r; -} \ No newline at end of file +}