diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 927ab5e..5f4c2c5 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -62,7 +62,7 @@ "languageVersion": "3.6" } ], - "generated": "2025-02-27T16:09:21.636346Z", + "generated": "2025-03-03T14:08:32.247456Z", "generator": "pub", "generatorVersion": "3.7.0", "flutterRoot": "file:///C:/Users/micwa/fvm/versions/stable", diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a2125..87258fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,5 @@ - +## 0.1.1 +- **FEAT** Added Map Extensions file and `MergeAllMaps` function. ## 0.1.0 - - **INIT**: Initial commit in the new repo. diff --git a/README.md b/README.md index 95dffb8..e6a1ed9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ 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_ + - **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. ☑️ - on _BorderRadiusGeometry_ diff --git a/lib/src/map_extensions.dart b/lib/src/map_extensions.dart new file mode 100644 index 0000000..de3cbf2 --- /dev/null +++ b/lib/src/map_extensions.dart @@ -0,0 +1,15 @@ +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); + } + }); + } + // + return r; +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index b056650..bbd0311 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: astromic_extensions description: The extensions module of the Astromic Presentation System. publish_to: "none" -version: 0.1.0 +version: 0.1.1 environment: sdk: ">=3.6.0"