MapUtils<K, V> extension
Extensions on Map for real-world utility operations.
- on
-
- Map<
K, V>
- Map<
Methods
-
camelCaseKeys(
) → Map< String, V> - Returns a new map with all string keys converted to camelCase.
-
camelCaseValues(
) → Map< K, String> - Returns a new map with all values converted to camelCase.
-
capitalizeKeys(
) → Map< String, V> - Returns a new map with all string keys capitalized.
-
capitalizeValues(
) → Map< K, String> - Returns a new map with all values capitalized.
-
compact(
) → Map< K, V> - Returns a new map with null values removed.
-
contains(
K key, V value) → bool -
Available on Map<
ReturnsK, V> , provided by the MapUtils extensiontrueif this map containskeywith exactlyvalue. -
deepGet(
List< String> path) → dynamic -
Available on Map<
Safely retrieves a deeply nested value using a list ofK, V> , provided by the MapUtils extensionpathkeys. -
deepMerge(
Map< K, V> other) → Map<K, V> -
Available on Map<
Recursively mergesK, V> , provided by the MapUtils extensionotherinto this map. For duplicate keys, if both values are Maps they are merged recursively; otherwiseother's value wins. -
deepSet(
List< String> path, dynamic value) → Map<String, dynamic> -
Available on Map<
Sets a deeply nested value atK, V> , provided by the MapUtils extensionpath, creating intermediate maps as needed. -
diff(
Map< K, V> other) → Map<K, V> -
Available on Map<
Returns entries in this map whose values differ fromK, V> , provided by the MapUtils extensionother. Includes keys present in this map but absent inother. -
filter(
bool predicate(K key, V value)) → Map< K, V> -
Available on Map<
Returns a new map with entries satisfyingK, V> , provided by the MapUtils extensionpredicate. -
filterEmpty(
) → Map< K, V> - Returns a new map with null and empty-string values removed.
-
filterKeys(
Iterable< K> keys) → Map<K, V> -
Available on Map<
Returns a new map with only the specifiedK, V> , provided by the MapUtils extensionkeys. -
filterNull(
) → Map< K, V> - Returns a new map with null values removed.
-
filterValues(
Iterable< V> values) → Map<K, V> -
Available on Map<
Returns a new map keeping only entries whose value is inK, V> , provided by the MapUtils extensionvalues. -
flatten(
{String separator = '.'}) → Map< String, dynamic> - Flattens nested maps to dot-notation keys.
-
getOrDefault(
K key, V defaultValue) → V -
Available on Map<
Returns the value forK, V> , provided by the MapUtils extensionkey, ordefaultValueif the key is absent. -
getOrPut(
K key, V compute()) → V -
Available on Map<
Returns the value forK, V> , provided by the MapUtils extensionkey. If absent, computes it withcompute, stores it, and returns it. -
invertMap(
) → Map< V, K> - Returns a new map with keys and values swapped. If duplicate values exist, later entries win.
-
kebabCaseKeys(
) → Map< String, V> - Returns a new map with all string keys converted to kebab-case.
-
kebabCaseValues(
) → Map< K, String> - Returns a new map with all values converted to kebab-case.
-
mapKeys<
K2> (K2 f(K key)) → Map< K2, V> -
Available on Map<
Returns a new map with keys transformed byK, V> , provided by the MapUtils extensionf. -
mapValues<
V2> (V2 f(V value)) → Map< K, V2> -
Available on Map<
Returns a new map with values transformed byK, V> , provided by the MapUtils extensionf. -
mergeWith(
Map< K, V> other, {V resolve(V existing, V incoming)?}) → Map<K, V> -
Available on Map<
Merges this map withK, V> , provided by the MapUtils extensionother. For duplicate keys,resolvedetermines the winner (defaults toother's value). -
omit(
List< K> keys) → Map<K, V> -
Available on Map<
Returns a new map with the specifiedK, V> , provided by the MapUtils extensionkeysremoved. -
partition(
bool predicate(K key, V value)) → Pair< Map< K, V> , Map<K, V> > -
Available on Map<
Splits this map into two maps based onK, V> , provided by the MapUtils extensionpredicate. First map: entries where predicate istrue. Second map: entries where predicate isfalse. -
pick(
List< K> keys) → Map<K, V> -
Available on Map<
Returns a new map containing only the specifiedK, V> , provided by the MapUtils extensionkeys. -
prefixKeys(
String prefix) → Map< String, V> -
Available on Map<
Returns a new map with all string keys prefixed byK, V> , provided by the MapUtils extensionprefix. -
prefixValues(
String prefix) → Map< K, String> -
Available on Map<
Returns a new map with all values prefixed byK, V> , provided by the MapUtils extensionprefix. -
reject(
bool predicate(K key, V value)) → Map< K, V> -
Available on Map<
Returns a new map with entries NOT satisfyingK, V> , provided by the MapUtils extensionpredicate. -
rejectKeys(
Iterable< K> keys) → Map<K, V> -
Available on Map<
Returns a new map excluding the specifiedK, V> , provided by the MapUtils extensionkeys. -
rejectValues(
Iterable< V> values) → Map<K, V> -
Available on Map<
Returns a new map excluding entries whose value is inK, V> , provided by the MapUtils extensionvalues. -
removeExact(
{required K key, required V value}) → bool -
Available on Map<
Removes the entry withK, V> , provided by the MapUtils extensionkeyonly if its value equalsvalue. Returnstrueif removed. -
renameKey(
K from, K to) → Map< K, V> -
Available on Map<
Returns a new map with the keyK, V> , provided by the MapUtils extensionfromrenamed toto. -
shift(
) → MapEntry< K, V> - Removes and returns the first entry in the map.
-
snakeCaseKeys(
) → Map< String, V> - Returns a new map with all string keys converted to snake_case.
-
snakeCaseValues(
) → Map< K, String> - Returns a new map with all values converted to snake_case.
-
suffixKeys(
String suffix) → Map< String, V> -
Available on Map<
Returns a new map with all string keys suffixed byK, V> , provided by the MapUtils extensionsuffix. -
suffixValues(
String suffix) → Map< K, String> -
Available on Map<
Returns a new map with all values suffixed byK, V> , provided by the MapUtils extensionsuffix. -
toQueryString(
) → String - Converts this map to a URL query string.
-
uniqueValues(
) → Map< K, V> - Removes duplicate values, keeping the first occurrence.