whenStateChanged method

  1. @override
void whenStateChanged(
  1. S previous,
  2. S current,
  3. VoidCallback _
)

Called when the notifier's state changes.

Implement this to determine when to trigger a rebuild based on state changes. previous is the previous state, current is the new state, and reBuild is a callback to trigger a rebuild.

Implementation

@override
void whenStateChanged(S previous, S current, _) {
  if (listenWhen?.call(previous, current) ?? true) listener(current);
}