Superposiciones

Represent dialogs y sheets con OverlayRequest? y render them through ScreenOverlayHost o AnimatedScreenOverlayHost.

Single overlay slot

Model overlay as OverlayRequest? y clear it a dismiss.

Dialog y sheet soporte

Use DialogRequest y BottomSheetRequest con optional payload data.

Back order control

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

Overlay Host Pattern

Keep overlay en state y 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 con canPopTop a avoid back-swipe inconsistency on iOS.