Represents a change in value, tracking both the previous and current states.
This is commonly used in reactive programming to notify about value changes, particularly in CollectiveValue implementations. It provides immutable access to both the before and after states of a value change.
Example:
final change = ValueChange(before: 'old', after: 'new');
print(change.before); // 'old'
print(change.after); // 'new'
The class supports creating unmodifiable versions of value changes through ValueChange.unmodifiable, which is useful when dealing with Cell values that should not be modified after creation.
- Implementers
Constructors
- ValueChange.new({required V? after, required V? before})
-
Creates a ValueChange with the given before and after values.
factory
-
ValueChange.unmodifiable(ValueChange<
V> source) -
Creates an unmodifiable version of an existing ValueChange.
factory
Properties
- after → V?
-
The value after the change occurred.
no setter
- before → V?
-
The value before the change occurred.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
unmodifiable
→ ValueChange<
V> -
Returns an unmodifiable version of this value change.
no setter
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