showSafaehDialog<T> function

Future<T?> showSafaehDialog<T>({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. bool barrierDismissible = true,
  4. Color? barrierColor,
  5. bool fadeScale = true,
  6. double railWidthOf(
    1. BuildContext context
    )?,
  7. Duration? motion,
  8. Curve? enterCurve,
  9. Curve? exitCurve,
  10. SafaehTransition? transition,
  11. bool useRootNavigator = true,
  12. SafaehFloatingAppearance? floatingAppearance,
  13. SafaehRouteOptions? route,
})

Centered dialog. railWidthOf is accepted for API compatibility and does not shift the panel — floating dialogs stay in the full viewport.

Unlike showSafaeh, this does not morph into a phone bottom sheet. SafaehRouteOptions.slideUp, SafaehRouteOptions.phonePlacement, and SafaehRouteOptions.tabletBreakpoint are ignored.

Implementation

Future<T?> showSafaehDialog<T>({
  required BuildContext context,
  required WidgetBuilder builder,
  bool barrierDismissible = true,
  Color? barrierColor,
  bool fadeScale = true,
  double Function(BuildContext context)? railWidthOf,
  Duration? motion,
  Curve? enterCurve,
  Curve? exitCurve,
  SafaehTransition? transition,
  bool useRootNavigator = true,
  SafaehFloatingAppearance? floatingAppearance,
  SafaehRouteOptions? route,
}) {
  final tokens = SafaehTheme.of(context);
  final resolvedBarrier = route?.barrierDismissible ?? barrierDismissible;
  final resolvedRoot = route?.useRootNavigator ?? useRootNavigator;
  final resolvedMotion = safaehResolvedMotion(
    context,
    motion ?? route?.motion ?? tokens.motion,
  );
  final resolvedFloatingAppearance =
      floatingAppearance ??
      route?.floatingAppearance ??
      tokens.floatingAppearance;
  final theme = Theme.of(context);

  return showGeneralDialog<T>(
    context: context,
    useRootNavigator: resolvedRoot,
    barrierDismissible: resolvedBarrier,
    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
    barrierColor:
        barrierColor ?? theme.colorScheme.scrim.withValues(alpha: 0.32),
    transitionDuration: resolvedMotion,
    pageBuilder: (ctx, animation, secondaryAnimation) {
      return _SafaehDialogHost(
        builder: builder,
        barrierDismissible: resolvedBarrier,
        fadeScale: fadeScale,
        openAnimation: animation,
        motion: resolvedMotion,
        enterCurve: enterCurve ?? route?.enterCurve ?? tokens.enterCurve,
        exitCurve: exitCurve ?? route?.exitCurve ?? tokens.exitCurve,
        railWidthOf: railWidthOf ?? route?.railWidthOf,
        maxWidth: route?.maxWidth ?? tokens.dialogMaxWidth,
        maxHeight: route?.maxHeight ?? MediaQuery.sizeOf(context).height * 0.85,
        transition: transition ?? route?.fadeScale,
        useRootNavigator: resolvedRoot,
        floatingAppearance: resolvedFloatingAppearance,
      );
    },
    transitionBuilder: (ctx, animation, secondaryAnimation, child) => child,
  );
}