useOnUnmount function

void useOnUnmount(
  1. VoidCallback cb
)

Calls a provided callback before widget is unmounted from widget tree.

useOnUnmount(() {
  print('unmounted');
});

Implementation

void useOnUnmount(VoidCallback cb) {
  useEffect(() => () => cb(), []);
}