MapExtension<T> extension

Extension on Map to provide additional functionality and utility methods.

This extension enhances the capabilities of Map<T, T> by adding methods for:

  • Checking key-value pair existence
  • Retrieving and casting values to specific types
  • Manipulating the map based on keys or values
  • Comparing maps
  • Safely accessing values with type-specific getters

These methods aim to simplify common map operations and provide more robust ways of working with map data in Dart.

on

Methods

diffKeys<K, V>(Map<K, V> map) Map<T, T>

Available on Map<T, T>, provided by the MapExtension extension

Returns a new map containing entries from this map that are not in map.
diffValues(Map<T, T> map) Map<T, T>

Available on Map<T, T>, provided by the MapExtension extension

Returns a new map containing entries from this map that are not in map.
doesntHave(String key, T value) bool

Available on Map<T, T>, provided by the MapExtension extension

Checks if the map does not contain the given key/value pair.
getBool(String key) bool

Available on Map<T, T>, provided by the MapExtension extension

Retrieves a boolean value for the given key.
getDouble(String key, {double? defaultValue}) double?

Available on Map<T, T>, provided by the MapExtension extension

Retrieves a double value for the given key.
getId({T? defaultValue}) → T?

Available on Map<T, T>, provided by the MapExtension extension

Retrieves the value associated with the 'id' key, if it exists.
getInt(String key, {int? defaultValue}) int?

Available on Map<T, T>, provided by the MapExtension extension

Retrieves an integer value for the given key.
getList<K>(String key) List<T>

Available on Map<T, T>, provided by the MapExtension extension

Retrieves a list of type T for the given key.
getString(String key, {String? defaultValue}) String?

Available on Map<T, T>, provided by the MapExtension extension

Retrieves a string value for the given key.
has(String key, dynamic value) bool

Available on Map<T, T>, provided by the MapExtension extension

Checks if the map contains the given key/value pair.
match(T condition, [String? byDefault = 'Invalid input']) Object?

Available on Map<T, T>, provided by the MapExtension extension

Retrieves the value associated with condition key.
pick(List<T> keys) Map<T, T>

Available on Map<T, T>, provided by the MapExtension extension

Creates a new map containing only the specified keys from this map.
removeNullValues() Map<T, T>

Available on Map<T, T>, provided by the MapExtension extension

Creates a new map excluding entries with null values from this map.
retainKeys(List<T> keys) Map<T, T>

Available on Map<T, T>, provided by the MapExtension extension

Removes key/value pairs from the map whose keys are not in the given keys list.