onStop method

  1. @protected
void onStop()

Called when the widget is no longer visible. Use this to:

  • Save data
  • Unregister listeners
  • Stop location updates
  • Cancel subscriptions
  • Release heavy resources

Example:

@override
void onStop() {
  super.onStop();
  _saveData();
  _unregisterEventListeners();
  _locationService.stopUpdates();
  _streamSubscription?.cancel();
  _heavyResources.release();
}

Implementation

@protected
void onStop() {}