onClose method

  1. @mustCallSuper
void onClose()

Lifecycle method called before controller disposal.

Override this to perform cleanup such as cancelling subscriptions, disposing reactive variables, closing streams, or releasing resources. This is called automatically when using ReactiveState with auto-dispose.

Always call super.onClose() when overriding.

Example:

@override
void onClose() {
  // Cancel subscriptions
  _streamSubscription.cancel();
  _timer.cancel();

  // Dispose reactive variables
  count.close();
  userData.close();

  super.onClose();
}

Implementation

@mustCallSuper
void onClose() {
  Logger.info('onClose of $runtimeType called', tag: 'ReactiveController');
}