onDetach method
Called during pop before the future is completed. Override for cleanup that must happen before the exit animation.
Implementation
@override
void onDetach() {
// A swipe-back (or any external pop) bypasses the Cancel button —
// roll the borrowed layer back exactly like Cancel, continuing
// from wherever the interactive revert left the render state.
if (!_resolved) {
_resolved = true;
layer.restoreSnapshotAnimated().unawaited();
}
super.onDetach();
}