onUnmounted function

void onUnmounted(
  1. void callback()
)

Registers a callback to run when the widget is unmounted.

This is called when the widget is being removed from the tree permanently. Use this for cleanup operations.

Example:

@override
setup(context, props) {
  onUnmounted(() {
    print('Cleaning up resources');
  });

  return () => Text('Hello');
}

Implementation

void onUnmounted(void Function() callback) {
  useHook(_OnUnmountedHook(callback));
}