useUnmount function
Flutter lifecycle hook that calls a function when the component will unmount. Use useLifecycles if you need both a mount and unmount function.
Implementation
void useUnmount(VoidCallback fn) {
final fnRef = useRef(fn);
// update the ref each build so if it change the newest callback will be invoked
fnRef.value = fn;
return useEffectOnce(() => () => fnRef.value());
}