MapUtils<K, V> extension

Extensions on Map for real-world utility operations.

on

Methods

camelCaseKeys() Map<String, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all string keys converted to camelCase.
camelCaseValues() Map<K, String>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all values converted to camelCase.
capitalizeKeys() Map<String, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all string keys capitalized.
capitalizeValues() Map<K, String>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all values capitalized.
compact() Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with null values removed.
contains(K key, V value) bool

Available on Map<K, V>, provided by the MapUtils extension

Returns true if this map contains key with exactly value.
deepGet(List<String> path) → dynamic

Available on Map<K, V>, provided by the MapUtils extension

Safely retrieves a deeply nested value using a list of path keys.
deepMerge(Map<K, V> other) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Recursively merges other into this map. For duplicate keys, if both values are Maps they are merged recursively; otherwise other's value wins.
deepSet(List<String> path, dynamic value) Map<String, dynamic>

Available on Map<K, V>, provided by the MapUtils extension

Sets a deeply nested value at path, creating intermediate maps as needed.
diff(Map<K, V> other) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns entries in this map whose values differ from other. Includes keys present in this map but absent in other.
filter(bool predicate(K key, V value)) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with entries satisfying predicate.
filterEmpty() Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with null and empty-string values removed.
filterKeys(Iterable<K> keys) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with only the specified keys.
filterNull() Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with null values removed.
filterValues(Iterable<V> values) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map keeping only entries whose value is in values.
flatten({String separator = '.'}) Map<String, dynamic>

Available on Map<K, V>, provided by the MapUtils extension

Flattens nested maps to dot-notation keys.
getOrDefault(K key, V defaultValue) → V

Available on Map<K, V>, provided by the MapUtils extension

Returns the value for key, or defaultValue if the key is absent.
getOrPut(K key, V compute()) → V

Available on Map<K, V>, provided by the MapUtils extension

Returns the value for key. If absent, computes it with compute, stores it, and returns it.
invertMap() Map<V, K>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with keys and values swapped. If duplicate values exist, later entries win.
kebabCaseKeys() Map<String, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all string keys converted to kebab-case.
kebabCaseValues() Map<K, String>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all values converted to kebab-case.
mapKeys<K2>(K2 f(K key)) Map<K2, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with keys transformed by f.
mapValues<V2>(V2 f(V value)) Map<K, V2>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with values transformed by f.
mergeWith(Map<K, V> other, {V resolve(V existing, V incoming)?}) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Merges this map with other. For duplicate keys, resolve determines the winner (defaults to other's value).
omit(List<K> keys) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with the specified keys removed.
partition(bool predicate(K key, V value)) Pair<Map<K, V>, Map<K, V>>

Available on Map<K, V>, provided by the MapUtils extension

Splits this map into two maps based on predicate. First map: entries where predicate is true. Second map: entries where predicate is false.
pick(List<K> keys) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map containing only the specified keys.
prefixKeys(String prefix) Map<String, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all string keys prefixed by prefix.
prefixValues(String prefix) Map<K, String>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all values prefixed by prefix.
reject(bool predicate(K key, V value)) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with entries NOT satisfying predicate.
rejectKeys(Iterable<K> keys) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map excluding the specified keys.
rejectValues(Iterable<V> values) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map excluding entries whose value is in values.
removeExact({required K key, required V value}) bool

Available on Map<K, V>, provided by the MapUtils extension

Removes the entry with key only if its value equals value. Returns true if removed.
renameKey(K from, K to) Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with the key from renamed to to.
shift() MapEntry<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Removes and returns the first entry in the map.
snakeCaseKeys() Map<String, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all string keys converted to snake_case.
snakeCaseValues() Map<K, String>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all values converted to snake_case.
suffixKeys(String suffix) Map<String, V>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all string keys suffixed by suffix.
suffixValues(String suffix) Map<K, String>

Available on Map<K, V>, provided by the MapUtils extension

Returns a new map with all values suffixed by suffix.
toQueryString() String

Available on Map<K, V>, provided by the MapUtils extension

Converts this map to a URL query string.
uniqueValues() Map<K, V>

Available on Map<K, V>, provided by the MapUtils extension

Removes duplicate values, keeping the first occurrence.