Notifier<S> class abstract

A concrete implementation of BaseNotifier that provides a default setState behavior.

Notifier updates its state and notifies listeners when setState is called, unless the state is unchanged and forced is false.

S is the type of state managed by the notifier.

This class integrates with NotifierLifecycle for automatic initialization and provides convenient methods for state management with fine-grained control.

Example usage:

class MyNotifier extends Notifier<int> {
  MyNotifier() : super(0);

  void increment() => setState(state + 1);
  void incrementSilently() => setState(state + 1, notify: false);
}

Constructors

Notifier.new(S state)
Creates a Notifier with the given initial state.

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state → S
Returns the current state.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Adds a listener to be notified when the state changes.
inherited
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
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → Never
Overrides notifyListeners to prevent direct calls.
inherited
onInit() → void
Called when the notifier is initialized and attached to the widget tree.
inherited
onUpdate(S state) → void
Called when the notifier's state is updated.
inherited
removeListener(VoidCallback listener) → void
Removes a previously added listener.
inherited
setState(S next, {bool notify = true, bool forced = false, bool equalityCheck(S curr, S next)?}) → void
Updates the state with the given next state.
stateEqualityCheck(S curr, S next) bool
A basic equality check that compares the current and next states using the == operator.
inherited
toString() String
Returns a string representation of the notifier.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited