LxMap<K, V> class

A reactive map that automatically notifies observers when its entries change.

LxMap implements the standard Dart Map interface but intercepts mutating methods to trigger notifications.

Usage

final config = <String, String>{}.lx;
config['theme'] = 'dark'; // Automatically notifies observers
Inheritance
Implemented types
Available extensions

Constructors

LxMap([Map<K, V>? initial, String? name])
Creates a reactive map.
LxMap.from(Map<K, V> other)
Creates an LxMap from an existing Map.
factory

Properties

entries Iterable<MapEntry<K, V>>
The map entries of this Map.
no setteroverride
graphDepth int
Returns the current depth in the dependency graph.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
hasListener bool
Whether there are active listeners.
no setterinherited
id int
A unique runtime identifier for this reactive instance.
finalinherited
isDisposed bool
Whether the reactive object has been closed/disposed.
no setterinherited
isEmpty bool
Whether there is no key/value pair in the map.
no setteroverride
isNotEmpty bool
Whether there is at least one key/value pair in the map.
no setteroverride
keys Iterable<K>
The keys of this Map.
no setteroverride
length int
The number of key/value pairs in the map.
no setteroverride
lx LxMap<K, V>

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

Wraps this map in a reactive LxMap.
no setter
name String?
An optional descriptive name for debugging and profiling.
getter/setter pairinherited
onCancel → void Function()?
Called when the stream is cancelled.
finalinherited
onListen → void Function()?
Called when the stream is listened to.
finalinherited
ownerId String?
The registration key of the owning controller, if applicable.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<Map<K, V>>
A Stream that emits the latest value whenever it updates.
no setterinherited
value Map<K, V>
The current state of the reactive object.
getter/setter pairinherited
values Iterable<V>
The values of this Map.
no setteroverride

Methods

addAll(Map<K, V> other) → void
Adds all key/value pairs of other to this map.
override
addEntries(Iterable<MapEntry<K, V>> entries) → void
Adds all key/value pairs of newEntries to this map.
override
addListener(void listener()) → void
Adds a listener.
inherited
assign(Map<K, V> other) → void
Replaces all entries with those from other in a single notification.
bind(Stream<Map<K, V>> externalStream) → void
Binds an external stream to this reactive variable.
inherited
call([Map<K, V>? v]) Map<K, V>
Functional-style update and retrieval.
inherited
cast<RK, RV>() Map<RK, RV>
Provides a view of this map as having RK keys and RV instances, if necessary.
override
clear() → void
Removes all entries from the map.
override
close() → void
Permanently closes the reactive object and releases all internal resources.
inherited
containsKey(Object? key) bool
Whether this map contains the given key.
override
containsValue(Object? val) bool
Whether this map contains the given value.
override
dispose() → void
Disposes the notifier.
inherited
forEach(void action(K key, V value)) → void
Applies action to each key/value pair of the map.
override
map<K2, V2>(MapEntry<K2, V2> transform(K key, V value)) Map<K2, V2>
Returns a new map where all entries of this map are transformed by the given convert function.
override
mutate(void mutator(Map<K, V> value)) → void
Mutates the value in place and triggers a refresh.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Alias for refresh.
inherited
putIfAbsent(K key, V ifAbsent()) → V
Look up the value of key, or add a new entry if it isn't there.
override
refresh() → void
Triggers a notification without changing the value.
inherited
remove(Object? key) → V?
Removes key and its associated value, if present, from the map.
override
removeListener(void listener()) → void
Removes a listener.
inherited
removeWhere(bool test(K key, V value)) → void
Removes all entries of this map that satisfy the given test.
override
setValueInternal(Map<K, V> val, {bool notifyListeners = true}) → void
Internal setter for subclasses (Computed, etc.)
inherited
toString() String
A string representation of this object.
inherited
transform<R>(Stream<R> transformer(Stream<Map<K, V>> stream)) LxStream<R>
Transforms the stream of changes using transformer.
inherited
unbind() → void
Unbinds any external stream.
inherited
update(K key, V update(V value), {V ifAbsent()?}) → V
Updates the value for the provided key.
override
updateAll(V update(K key, V value)) → void
Updates all values.
override
updateValue(Map<K, V> fn(Map<K, V> val)) → void
Updates the value using a transformation function.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](Object? key) → V?
The value for the given key, or null if key is not in the map.
override
operator []=(K key, V val) → void
Associates the key with the given value.
override