????

Represent dialogs ? sheets ?? OverlayRequest? ? render them through ScreenOverlayHost ?? AnimatedScreenOverlayHost.

Single overlay slot

Model overlay as OverlayRequest? ? clear it ? dismiss.

Dialog ? sheet ??

Use DialogRequest ? BottomSheetRequest ?? optional payload data.

Back order control

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

Overlay Host Pattern

Keep overlay ?? state ? 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,
  ),
);
Important

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