Obj class
Static utility methods for working with maps using dot notation.
final user = {'profile': {'name': 'Anna', 'age': 30}};
Obj.get(user, 'profile.name'); // 'Anna'
Obj.has(user, 'profile.email'); // false
Obj.set(user, 'profile.email', 'a@b'); // mutates user
Obj.dot(user); // {'profile.name': 'Anna', 'profile.age': 30}
Available helpers:
Read:
Typed read:
Write (mutating):
Subset:
Filter:
Transform:
Flatten / inflate:
Merge / compare / query:
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
add(
Map map, String key, dynamic value) → Map -
Adds
valueatkeyonly if no value currently exists there. -
deepEquals(
dynamic a, dynamic b) → bool -
Returns true when
aandbare structurally equal. -
divide<
K, V> (Map< K, V> map) → List<List> -
Splits
mapinto a[keys, values]pair. -
dot(
Map map, [String prefix = '']) → Map< String, dynamic> - Flattens a nested map into a single-level map keyed by dot-paths.
-
except<
K, V> (Map< K, V> map, Iterable<K> keys) → Map<K, V> -
Returns a new map containing all entries except those whose keys are in
keys. -
exists(
Map map, Object key) → bool -
Returns true when
maphaskeyat the top level (no traversal). -
flip<
K, V> (Map< K, V> map) → Map<V, K> - Swaps keys ↔ values. When values collide, the last entry wins.
-
forget(
Map map, String key) → Map -
Removes
key(dot notation) frommap. Returns the map for chaining. -
get(
Map map, String key, [dynamic defaultValue]) → dynamic -
Returns the value at
keyinmapusing dot notation, ordefaultValuewhen the path is missing. -
getBool(
Map map, String key, [bool? defaultValue]) → bool? -
Returns the value at
keycoerced tobool, ordefaultValue. -
getDouble(
Map map, String key, [double? defaultValue]) → double? -
Returns the value at
keycoerced todouble, ordefaultValue. -
getInt(
Map map, String key, [int? defaultValue]) → int? -
Returns the value at
keycoerced toint, ordefaultValue. -
getList(
Map map, String key, [List? defaultValue]) → List? -
Returns the value at
keywhen it is aList, otherwisedefaultValue. -
getMap(
Map map, String key, [Map? defaultValue]) → Map? -
Returns the value at
keywhen it is aMap, otherwisedefaultValue. -
getString(
Map map, String key, [String? defaultValue]) → String? -
Returns the value at
keycoerced toString, ordefaultValue. -
has(
Map map, String key) → bool -
Returns true when
maphas a value atkey(dot notation). -
hasAll(
Map map, Iterable< String> keys) → bool -
Returns true when every one of
keysresolves inmap. -
hasAny(
Map map, Iterable< String> keys) → bool -
Returns true when any of
keysresolves inmap. -
mapKeys<
K, V, K2> (Map< K, V> map, K2 fn(K)) → Map<K2, V> -
Returns a new map with each key transformed by
fn. -
mapValues<
K, V, V2> (Map< K, V> map, V2 fn(V)) → Map<K, V2> -
Returns a new map with each value transformed by
fn. -
merge(
Map target, Map source) → Map< String, dynamic> -
Recursively merges
sourceintotargetand returns a new map. On key collision,sourcewins; nested maps are merged. -
only<
K, V> (Map< K, V> map, Iterable<K> keys) → Map<K, V> -
Returns a new map containing only the entries whose keys are in
keys. -
prependKeysWith<
V> (Map< String, V> map, String prefix) → Map<String, V> -
Prefixes every top-level key in
mapwithprefix. -
pull(
Map map, String key, [dynamic defaultValue]) → dynamic -
Returns the value at
keyand removes it frommap. -
query(
Map< String, dynamic> map) → String -
Encodes
mapas a URL query string. -
set(
Map map, String key, dynamic value) → Map -
Sets
valueatkeyinmap, creating nested maps along the path. Mutatesmapin place and returns it for chaining. -
undot(
Map< String, dynamic> map) → Map<String, dynamic> - Inflates a dot-keyed map back into a nested structure.
-
whereNotEmpty<
K, V> (Map< K, V> map) → Map<K, V> -
Returns a new map with entries whose values are
nullor empty (emptyString,Iterable, orMap) removed. -
whereNotNull<
K, V> (Map< K, V?> map) → Map<K, V> -
Returns a new map with entries whose values are
nullremoved.