tryUnmount method

void tryUnmount({
  1. void onMaybeUnmounted(
    1. bool isUnmounted
    )?,
})

Attempts to unmount the rendered component, calling onMaybeUnmounted with whether the component was actually unmounted.

Unmounting could fail if a call to render is batched in with this unmount during the propagation of this event. In that case, some other call wanted something rendered and trumped the unmount request.

This behavior allows the same SafeRenderManager instance to be used to render/unmount a single content area without calls interfering with each other.

If nothing is currently rendered, onMaybeUnmounted will be called immediately.

Implementation

void tryUnmount({void Function(bool isUnmounted)? onMaybeUnmounted}) {
  // Check here since we call _tryUnmountContent in this class's disposal logic.
  _checkDisposalState();
  _safeUnmountContent(onMaybeUnmounted: onMaybeUnmounted, force: false);
}