MapChangeNotifier<K, T> class
An implementation of ChangeNotifier that allows implementers to interact with this provider as if it were a Map and be notified when any changes to the map have been made
Like ChangeNotifier, this is optimized for small numbers of listeners. It is O(N) for adding and removing listeners.
K
is the type of the Key to be used by this map. It is usually a String,
but can be any subclass of Object. It must implement operator==
and
hashCode
T
is the type of the Value to be used by this map. It can be any subclass
of Object and has no special requirements.
- Inheritance
-
- Object
- ChangeNotifier
- CollectionChangeNotifier
- MapChangeNotifier
- Mixed-in types
-
- MapMixin<
K, T>
- MapMixin<
Constructors
-
MapChangeNotifier([Map<
K, T> ? backingMap])
Properties
-
entries
→ Iterable<
MapEntry< K, T> > -
The map entries of this Map.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isEmpty → bool
-
Whether there is no key/value pair in the map.
no setterinherited
- isNotEmpty → bool
-
Whether there is at least one key/value pair in the map.
no setterinherited
-
keys
→ Iterable<
K> -
The keys of
this
.no setteroverride - length → int
-
The number of key/value pairs in the map.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Iterable<
T> -
The values of this Map.
no setterinherited
Methods
-
addAll(
Map< K, T> other) → void -
Adds all the key/value pairs of
other
to this map. Listeners are notified after all values have been added.override -
addEntries(
Iterable< MapEntry< newEntries) → voidK, T> > -
Adds all the key/value pairs of
newEntries
to othis map. Listeners are notified after all the entries have been added.override -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
cast<
RK, RV> () → Map< RK, RV> -
Provides a view of this map as having
RK
keys andRV
instances, if necessary.inherited -
clear(
) → void -
Removes all pairs from the map.
override
-
containsKey(
Object? key) → bool -
Whether this map contains the given
key
.inherited -
containsValue(
Object? value) → bool -
Whether this map contains the given
value
.inherited -
dispose(
) → void -
Discards the internal resources used by the object.
After this is called, the object is not in a usable state and should be discarded.
override
-
forEach(
void action(K key, T value)) → void -
Applies
action
to each key/value pair of the map.inherited -
map<
K2, V2> (MapEntry< K2, V2> transform(K key, T value)) → Map<K2, V2> -
Returns a new map where all entries of this map are transformed by
the given
convert
function.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Notify all the listeners, respecting our paused state falg
inherited
-
pauseNotifications<
T> (ChangeHandler< T> handler, [bool notifyAfter = false]) → T -
Pause notifications until after a synchronous handler has completed.
If
notifyAfter
istrue
, then listeners will automatically be notified after the callback completes. Otherwise, you must notify the listeners;inherited -
pauseNotificationsAsync<
T> (AsyncChangeHandler< T> handler, [bool notifyAfter = false]) → Future<T> -
Pause notifications until after an asynchronous handler has completed.
If
notifyAfter
istrue
, then listeners will automatically be notified after the callback completes. Otherwise, you must notify the listeners;inherited -
putIfAbsent(
K key, T ifAbsent()) → T -
Look up the value of
key
, or add a new entry if it isn't there.inherited -
remove(
Object? key) → T? -
Removes
key
and its associated value, if present, from the map.override -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeWhere(
bool test(K key, T value)) → void -
Remove all entries of this map that satisfy
test
Listeners are notified after all removals have taken place.override -
toString(
) → String -
A string representation of this object.
inherited
-
update(
K key, T update(T value), {T ifAbsent()?}) → T -
Updates the value for the provided
key
.inherited -
updateAll(
T update(K key, T value)) → void -
Updates all values.
Listeners are notified after all values have been updated.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
Object? key) → T? -
Returns the value for the given
key
or null ifkey
is not in the map.override -
operator []=(
K key, T value) → void -
Associates the
key
with the givenvalue
.override