onUnmount method

void onUnmount(
  1. BuildContext context
)

Called when the resource is unmounted from the widget tree.

This method is invoked when:

  • The JoltProvider widget is unmounted
  • A new resource is created to replace this one (in update)

Use this to:

  • Clean up resources (cancel timers, dispose subscriptions, etc.)
  • Stop background processes
  • Remove listeners or observers

The context parameter provides access to the widget tree context.

Example

@override
void onUnmount(BuildContext context) {
  super.onUnmount(context);
  _subscription?.cancel();
  _timer?.cancel();
}

Implementation

void onUnmount(BuildContext context) {}