state property
T
get
state
The current value of this signal.
Setting this property will update the signal's state and notify all listeners if the new value is different from the current value.
Example:
final counter = Signal<int>(0);
print(counter.state); // 0
counter.state = 5; // Triggers notifications
Implementation
T get state => _state;
set
state
(T newValue)
Updates the signal's state and notifies listeners if the value changed.
If newValue
is equal to the current state (using ==
), no notification
is sent and listeners are not called.
Implementation
set state(T newValue) {
if (_state == newValue) return;
onChanged(_state, newValue);
_state = newValue;
if (_shouldNotify) notify();
}