closeOverlay<T> method

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

Close the current overlay returning the result, if provided

Implementation

void closeOverlay<T>({
  String? id,
  T? result,
}) {
  final delegate = searchDelegate(id);
  final navigatorState = delegate.navigatorKey.currentState;

  // Validate navigator state and that we can actually pop
  if (navigatorState == null) {
    Jet.log('Cannot close overlay: navigator state is null', isError: true);
    return;
  }

  if (navigatorState.canPop()) {
    navigatorState.pop(result);
  }
}