Screen-local Overlay State

Represent dialogs and sheets with OverlayRequest? and render them through ScreenOverlayHost or AnimatedScreenOverlayHost.

Single overlay slot

Model overlay as OverlayRequest? and clear it to dismiss.

Dialog and sheet support

Use DialogRequest and BottomSheetRequest with optional payload data.

Back order control

Dismiss overlay first, then pop pages, via back-scope widgets.

Overlay Host Pattern

Keep overlay in state and build overlay UI through overlayBuilder.

Overlay State Rule

Animated Overlay Host

return AnimatedScreenOverlayHost(
  overlay: _overlay,
  onDismiss: _dismissOverlay,
  overlayBuilder: (context, req, dismiss) => switch (req) {
    DialogRequest(key: 'hello') => AlertDialog(
      title: const Text('Hello'),
      actions: [TextButton(onPressed: dismiss, child: const Text('Close'))],
    ),
    _ => null,
  },
  child: DeclarativePagesNavigator(
    pages: _pages,
    buildPage: _buildPage,
    onPopTop: _popTop,
    canPopTop: () => _overlay == null,
  ),
);
Важно

When overlay is visible, block pop gestures with canPopTop to avoid back-swipe inconsistency on iOS.