MapExtensions<K, V> extension
Common Map extensions
- on
-
- Map<
K, V>
- Map<
Methods
-
filterKeys(
bool predicate(K key)) → Map< K, V> - Filters the map based on a condition applied to its keys.
-
filterValues(
bool predicate(V value)) → Map< K, V> - Filters the map based on a condition applied to its values.
-
getOrDefault(
K key, V defaultValue) → V? -
Retrieves the value for the specified
key
from the map. If the key does not exist, returns the provideddefaultValue
. -
getOrNull(
K key) → V? -
Retrieves the value for the specified
key
from the map. If the key does not exist, returns null. -
invert(
) → Map< V, K> - Inverts the map by swapping its keys and values. Assumes that the values are unique.
-
merge(
Map< K, V> other, V resolve(V v1, V v2)?) → Map<K, V> -
Merges this map with another
other
map. For duplicate keys,resolve
determines the final value. -
toJsonString(
) → String - Converts the map to a JSON string.
-
toJsonStringWithIndent(
[int spaces = 2]) → String - Converts the map to a formatted JSON string, with specified indentation.