closeOverlay<T> method

void closeOverlay<T>({
  1. String? id,
  2. T? result,
})

Close the current overlay (e.g. dialog or bottom sheet) returning the result, if provided.

Page routes managed by the router delegate are never popped by this method. If the navigator still shows a page that was already removed declaratively (for example by a back call awaited in the same frame), the pop is retried once after the pending frame settles, so the actual overlay is closed instead of a page.

Implementation

void closeOverlay<T>({String? id, T? result}) {
  final topRoute = _topRoute(id: id);
  if (topRoute == null) return;

  _popOverlayRoute(topRoute, id: id, result: result);
}