onUpdate method

void onUpdate(
  1. S state
)
inherited

Called when the notifier's state is updated.

Override this method to perform side effects or additional logic when the state changes. This method is called after the state has been updated and listeners have been notified.

state is the new state value after the update.

Use this method for:

  • Logging state changes
  • Triggering side effects based on state changes
  • Updating external systems
  • Analytics tracking

Example:

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

  @override
  void onUpdated(int state) {
    // Log state changes
    print('State updated to: $state');

    // Trigger side effects
    if (state > 10) {
      _showNotification('High value reached!');
    }
  }
}

Implementation

void onUpdate(S state) {}