VN<T> class
A simplified and enhanced abstraction for working with ValueNotifier.
The VN class streamlines the use of ValueNotifier, adding flexibility
through custom change types and advanced features such as merging multiple
VN instances.
Features:
- Customizable change behaviors via ChangeType.
- Built-in listener management.
- Easy merging of two
VNinstances into a single, derivedVN. - Utility methods for notifying listeners, silent updates, and conditional updates.
Parameters:
T- The type of the value managed by thisVNinstance.
- Implemented types
- Mixed-in types
- Available extensions
Constructors
- VN(T initialValue, [ChangeType changeType = ChangeType.smart])
-
Creates a
VNinstance with an initial value and optional change behavior.
Properties
- changeType → ChangeType
-
The change behavior applied to this VN.
final
- first → T
-
Available on VN<
Returns the first element in the iterable.Iterable< , provided by the BetterIterableNotifications extensionT> >no setter - first → T
-
Available on VN<
Returns the first element in the set.Set< , provided by the BetterSetNotifications extensionT> >no setter - firstOrNull → T?
-
Available on VN<
Returns the first element in the iterable, orIterable< , provided by the BetterIterableNotifications extensionT> >nullif the iterable is empty.no setter - firstOrNull → T?
-
Available on VN<
Returns the first element in the set, orSet< , provided by the BetterSetNotifications extensionT> >nullif the set is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Indicates whether this
VNhas active listeners.no setteroverride - isEmpty → bool
-
Available on VN<
ReturnsIterable< , provided by the BetterIterableNotifications extensionT> >trueif the iterable has no elements.no setter - isEmpty → bool
-
Available on VN<
ReturnsMap< , provided by the BetterMapNotifications extensionK, V> >trueif the map has no key-value pairs.no setter - isEmpty → bool
-
Available on VN<
ReturnsSet< , provided by the BetterSetNotifications extensionT> >trueif the set has no elements.no setter - isNotEmpty → bool
-
Available on VN<
ReturnsIterable< , provided by the BetterIterableNotifications extensionT> >trueif the iterable has one or more elements.no setter - isNotEmpty → bool
-
Available on VN<
ReturnsMap< , provided by the BetterMapNotifications extensionK, V> >trueif the map has one or more key-value pairs.no setter - isNotEmpty → bool
-
Available on VN<
ReturnsSet< , provided by the BetterSetNotifications extensionT> >trueif the set has one or more elements.no setter -
keys
→ Iterable<
K> -
Available on VN<
Returns an iterable of all keys in the map.Map< , provided by the BetterMapNotifications extensionK, V> >no setter - last → T
-
Available on VN<
Returns the last element in the iterable.Iterable< , provided by the BetterIterableNotifications extensionT> >no setter - last → T
-
Available on VN<
Returns the last element in the set.Set< , provided by the BetterSetNotifications extensionT> >no setter - lastOrNull → T?
-
Available on VN<
Returns the last element in the iterable, orIterable< , provided by the BetterIterableNotifications extensionT> >nullif the iterable is empty.no setter - lastOrNull → T?
-
Available on VN<
Returns the last element in the set, orSet< , provided by the BetterSetNotifications extensionT> >nullif the set is empty.no setter - length → int
-
Available on VN<
Returns the number of elements in the iterable.Iterable< , provided by the BetterIterableNotifications extensionT> >no setter - length → int
-
Available on VN<
Returns the number of key-value pairs in the map.Map< , provided by the BetterMapNotifications extensionK, V> >no setter - length → int
-
Available on VN<
Returns the number of elements in the set.Set< , provided by the BetterSetNotifications extensionT> >no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
Gets the current value of this
VN.getter/setter pairoverride-getter -
values
→ Iterable<
V> -
Available on VN<
Returns an iterable of all values in the map.Map< , provided by the BetterMapNotifications extensionK, V> >no setter
Methods
-
add(
T value) → bool -
Available on VN<
Adds the givenSet< , provided by the BetterSetNotifications extensionT> >valueto the set. -
addAll(
Iterable< T> values) → void -
Available on VN<
Adds all elements from the givenSet< , provided by the BetterSetNotifications extensionT> >valuesto the set. -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clear(
) → void -
Available on VN<
Removes all elements from the set.Set< , provided by the BetterSetNotifications extensionT> > -
clear(
) → void -
Available on VN<
Removes all key-value pairs from the map.Map< , provided by the BetterMapNotifications extensionK, V> > -
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
firstWhere(
bool function(T function)) → T -
Available on VN<
Returns the first element that satisfies the given predicateSet< , provided by the BetterSetNotifications extensionT> >function. -
firstWhere(
bool function(T)) → T -
Available on VN<
Returns the first element that satisfies the given predicateIterable< , provided by the BetterIterableNotifications extensionT> >function. -
hardAdd(
T value) → void -
Available on VN<
Adds the givenList< , provided by the BetterListNotifications extensionT> >valueto the list and notifies listeners. -
hardAddAll(
Iterable< T> value) → void -
Available on VN<
Appends all elements from the given iterableList< , provided by the BetterListNotifications extensionT> >valueto the list and notifies listeners. -
hardClear(
) → void -
Available on VN<
Removes all elements from the set and notifies listeners.Set< , provided by the BetterSetNotifications extensionT> > -
hardClear(
) → void -
Available on VN<
Removes all key-value pairs from the map and notifies listeners.Map< , provided by the BetterMapNotifications extensionK, V> > -
hardRemove(
Object? value) → bool -
Available on VN<
Removes the first occurrence of the givenList< , provided by the BetterListNotifications extensionT> >valuefrom the list and notifies listeners. -
hardRemove(
Object? value) → bool -
Available on VN<
Removes the givenSet< , provided by the BetterSetNotifications extensionT> >valuefrom the set and notifies listeners. -
hardRemove(
K key) → V? -
Available on VN<
Removes the key-value pair with the givenMap< , provided by the BetterMapNotifications extensionK, V> >keyfrom the map and notifies listeners. -
hardRemoveAt(
int index) → T -
Available on VN<
Removes the element at the specifiedList< , provided by the BetterListNotifications extensionT> >indexfrom the list and notifies listeners. -
hardRemoveWhere(
bool where(T)) → void -
Available on VN<
Removes all elements from the set that satisfy the predicateSet< , provided by the BetterSetNotifications extensionT> >whereand notifies listeners. -
hardRemoveWhere(
bool where(K key, V value)) → void -
Available on VN<
Removes all key-value pairs from the map that satisfy the predicateMap< , provided by the BetterMapNotifications extensionK, V> >whereand notifies listeners. -
hardRemoveWhere(
bool where(T)) → void -
Available on VN<
Removes all elements that satisfy the given predicateList< , provided by the BetterListNotifications extensionT> >whereand notifies listeners. -
hardSet(
T newValue) → void - Updates the value and notifies listeners unconditionally.
-
lastWhere(
bool function(T function)) → T -
Available on VN<
Returns the last element that satisfies the given predicateSet< , provided by the BetterSetNotifications extensionT> >function. -
lastWhere(
bool function(T)) → T -
Available on VN<
Returns the last element that satisfies the given predicateIterable< , provided by the BetterIterableNotifications extensionT> >function. -
map<
K2, V2> (MapEntry< K2, V2> converter(K k, V v)) → Map<K2, V2> -
Available on VN<
Transforms the map by applying a function to all its key-value pairs.Map< , provided by the BetterMapNotifications extensionK, V> > -
map<
R> (R map(T e)) → Iterable< R> -
Available on VN<
Transforms the set by applying a function to all its elements.Set< , provided by the BetterSetNotifications extensionT> > -
merge<
K, R> (VN< R> other, K initialValue, void listener(T left, R right, void emitter(K value))) → VN<K> -
Merges this
VNwith anotherVNinto a derivedVN. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
) → void - Notifies all listeners about a change in value.
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
remove(
K key) → V? -
Available on VN<
Removes the key-value pair with the givenMap< , provided by the BetterMapNotifications extensionK, V> >keyfrom the map. -
remove(
Object? value) → bool -
Available on VN<
Removes the givenSet< , provided by the BetterSetNotifications extensionT> >valuefrom the set. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeWhere(
bool where(K key, V value)) → void -
Available on VN<
Removes all key-value pairs from the map that satisfy the given predicateMap< , provided by the BetterMapNotifications extensionK, V> >where. -
removeWhere(
bool where(T)) → void -
Available on VN<
Removes all elements from the set that satisfy the given predicateSet< , provided by the BetterSetNotifications extensionT> >where. -
silentAdd(
T value) → void -
Available on VN<
Adds the givenList< , provided by the BetterListNotifications extensionT> >valueto the list without notifying listeners. -
silentAdd(
T value) → bool -
Available on VN<
Adds the givenSet< , provided by the BetterSetNotifications extensionT> >valueto the set without notifying listeners. -
silentAddAll(
Iterable< T> value) → void -
Available on VN<
Appends all elements from the given iterableList< , provided by the BetterListNotifications extensionT> >valueto the list without notifying listeners. -
silentAddAll(
Iterable< T> values) → void -
Available on VN<
Adds all elements from the givenSet< , provided by the BetterSetNotifications extensionT> >valuesto the set without notifying listeners. -
silentClear(
) → void -
Available on VN<
Removes all key-value pairs from the map without notifying listeners.Map< , provided by the BetterMapNotifications extensionK, V> > -
silentClear(
) → void -
Available on VN<
Removes all elements from the set without notifying listeners.Set< , provided by the BetterSetNotifications extensionT> > -
silentRemove(
Object? value) → bool -
Available on VN<
Removes the first occurrence of the givenList< , provided by the BetterListNotifications extensionT> >valuefrom the list without notifying listeners. -
silentRemove(
Object? value) → bool -
Available on VN<
Removes the givenSet< , provided by the BetterSetNotifications extensionT> >valuefrom the set without notifying listeners. -
silentRemove(
K key) → V? -
Available on VN<
Removes the key-value pair with the givenMap< , provided by the BetterMapNotifications extensionK, V> >keyfrom the map without notifying listeners. -
silentRemoveAt(
int index) → T -
Available on VN<
Removes the element at the specifiedList< , provided by the BetterListNotifications extensionT> >indexfrom the list without notifying listeners. -
silentRemoveWhere(
bool where(T)) → void -
Available on VN<
Removes all elements that satisfy the given predicateList< , provided by the BetterListNotifications extensionT> >wherewithout notifying listeners. -
silentRemoveWhere(
bool where(K key, V value)) → void -
Available on VN<
Removes all key-value pairs from the map that satisfy the predicateMap< , provided by the BetterMapNotifications extensionK, V> >wherewithout notifying listeners. -
silentRemoveWhere(
bool where(T)) → void -
Available on VN<
Removes all elements from the set that satisfy the predicateSet< , provided by the BetterSetNotifications extensionT> >wherewithout notifying listeners. -
silentSet(
T newValue) → void - Updates the value without notifying listeners.
-
smartAdd(
T value) → void -
Available on VN<
Adds the givenList< , provided by the BetterListNotifications extensionT> >valueto the list, with behavior determined by ChangeType. -
smartAdd(
T value) → bool -
Available on VN<
Adds the givenSet< , provided by the BetterSetNotifications extensionT> >valueto the set and notifies listeners if the value was added. -
smartAddAll(
Iterable< T> value) → void -
Available on VN<
Appends all elements from the given iterableList< , provided by the BetterListNotifications extensionT> >valueto the list, with behavior determined by ChangeType. -
smartAddAll(
Iterable< T> values) → void -
Available on VN<
Adds all elements from the givenSet< , provided by the BetterSetNotifications extensionT> >valuesto the set and notifies listeners if the set changed. -
smartClear(
) → void -
Available on VN<
Removes all key-value pairs from the map, with behavior determined by ChangeType.Map< , provided by the BetterMapNotifications extensionK, V> > -
smartClear(
) → void -
Available on VN<
Removes all elements from the set and notifies listeners if the set was not empty.Set< , provided by the BetterSetNotifications extensionT> > -
smartRemove(
Object? value) → bool -
Available on VN<
Removes the first occurrence of the givenList< , provided by the BetterListNotifications extensionT> >valuefrom the list, with behavior determined by ChangeType. -
smartRemove(
K key) → V? -
Available on VN<
Removes the key-value pair with the givenMap< , provided by the BetterMapNotifications extensionK, V> >keyfrom the map, with behavior determined by ChangeType. -
smartRemove(
Object? value) → bool -
Available on VN<
Removes the givenSet< , provided by the BetterSetNotifications extensionT> >valuefrom the set and notifies listeners if the set changed. -
smartRemoveAt(
int index) → T -
Available on VN<
Removes the element at the specifiedList< , provided by the BetterListNotifications extensionT> >indexfrom the list, with behavior determined by ChangeType. -
smartRemoveWhere(
bool where(T)) → void -
Available on VN<
Removes all elements that satisfy the given predicateList< , provided by the BetterListNotifications extensionT> >where, with behavior determined by ChangeType. -
smartRemoveWhere(
bool where(T)) → void -
Available on VN<
Removes all elements from the set that satisfy the predicateSet< , provided by the BetterSetNotifications extensionT> >where, with behavior determined by ChangeType. -
smartRemoveWhere(
bool where(K key, V value)) → void -
Available on VN<
Removes all key-value pairs from the map that satisfy the predicateMap< , provided by the BetterMapNotifications extensionK, V> >where, with behavior determined by ChangeType. -
smartSet(
T newValue) → void - Updates the value if it differs from the current value, and notifies listeners.
-
toList(
) → List< T> -
Available on VN<
Returns a new list containing all elements of the iterable.Iterable< , provided by the BetterIterableNotifications extensionT> > -
toString(
) → String -
Returns a string representation of this
VN.override -
where(
bool function(T function)) → Iterable< T> -
Available on VN<
Returns a new lazy Iterable with all elements that satisfy the predicateSet< , provided by the BetterSetNotifications extensionT> >function. -
where(
bool function(T)) → Iterable< T> -
Available on VN<
Returns a new lazy Iterable with all elements that satisfy the predicateIterable< , provided by the BetterIterableNotifications extensionT> >function.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → T -
Available on VN<
Gets the element at the specifiedIterable< , provided by the BetterIterableNotifications extensionT> >indexin the iterable. -
operator [](
int index) → T -
Available on VN<
Gets the element at the specifiedList< , provided by the BetterListNotifications extensionT> >indexin the list. -
operator [](
K key) → V? -
Available on VN<
Retrieves the value associated with the givenMap< , provided by the BetterMapNotifications extensionK, V> >keyin the map. -
operator [](
int index) → T -
Available on VN<
Retrieves the element at the specifiedSet< , provided by the BetterSetNotifications extensionT> >indexin the set. -
operator []=(
int index, T value) → void -
Available on VN<
Sets the element at the specifiedList< , provided by the BetterListNotifications extensionT> >indexin the list to the givenvalue. -
operator []=(
K key, V value) → void -
Available on VN<
Associates the givenMap< , provided by the BetterMapNotifications extensionK, V> >keywith the givenvaluein the map.