showSafaeh<T> function
Future<T?>
showSafaeh<T>({
- required BuildContext context,
- required Widget child,
- String? title,
- SafaehTitleBuilder? titleBuilder,
- Widget? tabletTopBarAction,
- double? maxWidth,
- double? maxHeight,
- bool useSafeArea = true,
- bool showDragHandle = true,
- bool enableDrag = true,
- ShapeBorder? sheetShape,
- bool barrierDismissible = true,
- EdgeInsetsGeometry? contentPadding,
- double? tabletBreakpoint,
- double? dialogMaxWidth,
- Duration? motion,
- Curve? enterCurve,
- Curve? exitCurve,
- double railWidthOf(
- BuildContext context
- SafaehTransition? fadeScale,
- SafaehTransition? slideUp,
- SafaehPhoneSheetPlacement phonePlacement = SafaehPhoneSheetPlacement.bottom,
- T? dismissValue,
- String? dismissLabel,
- String? closeTooltip,
- bool paintPhoneTitle = true,
- SafaehFloatingAppearance? floatingAppearance,
- SafaehRouteOptions? route,
Shows child as a centered dialog on tablet+ and a bottom sheet on phone.
The same route morphs when the viewport crosses the tablet breakpoint.
Implementation
Future<T?> showSafaeh<T>({
required BuildContext context,
required Widget child,
String? title,
SafaehTitleBuilder? titleBuilder,
Widget? tabletTopBarAction,
double? maxWidth,
double? maxHeight,
bool useSafeArea = true,
bool showDragHandle = true,
bool enableDrag = true,
ShapeBorder? sheetShape,
bool barrierDismissible = true,
EdgeInsetsGeometry? contentPadding,
double? tabletBreakpoint,
double? dialogMaxWidth,
Duration? motion,
Curve? enterCurve,
Curve? exitCurve,
double Function(BuildContext context)? railWidthOf,
SafaehTransition? fadeScale,
SafaehTransition? slideUp,
SafaehPhoneSheetPlacement phonePlacement = SafaehPhoneSheetPlacement.bottom,
T? dismissValue,
bool useRootNavigator = true,
String? dismissLabel,
String? closeTooltip,
bool paintPhoneTitle = true,
SafaehFloatingAppearance? floatingAppearance,
SafaehRouteOptions? route,
}) {
final tokens = SafaehTheme.of(context);
final resolvedRail = railWidthOf ?? route?.railWidthOf;
final resolvedMaxWidth = maxWidth ?? route?.maxWidth;
final resolvedMaxHeight = maxHeight ?? route?.maxHeight;
final resolvedBarrier = route?.barrierDismissible ?? barrierDismissible;
final resolvedMotion = safaehResolvedMotion(
context,
motion ?? route?.motion ?? tokens.motion,
);
final resolvedEnter = enterCurve ?? route?.enterCurve ?? tokens.enterCurve;
final resolvedExit = exitCurve ?? route?.exitCurve ?? tokens.exitCurve;
final resolvedFade = fadeScale ?? route?.fadeScale;
final resolvedSlide = slideUp ?? route?.slideUp;
final resolvedPlacement = route?.phonePlacement ?? phonePlacement;
final resolvedRoot = route?.useRootNavigator ?? useRootNavigator;
final resolvedBreakpoint = tabletBreakpoint ?? route?.tabletBreakpoint;
final resolvedDismissLabel = dismissLabel ?? route?.dismissLabel;
final resolvedCloseTooltip = closeTooltip ?? route?.closeTooltip;
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: theme.colorScheme.scrim.withValues(alpha: 0.32),
transitionDuration: resolvedMotion,
pageBuilder: (ctx, animation, secondaryAnimation) {
return _AdaptiveSheetHost(
title: title,
titleBuilder: titleBuilder,
tabletTopBarAction: tabletTopBarAction,
maxWidth: resolvedMaxWidth,
maxHeight: resolvedMaxHeight,
useSafeArea: useSafeArea,
showDragHandle: showDragHandle,
enableDrag: enableDrag,
sheetShape: sheetShape,
barrierDismissible: resolvedBarrier,
openAnimation: animation,
contentPadding: contentPadding,
tabletBreakpoint: resolvedBreakpoint ?? tokens.tabletBreakpoint,
dialogMaxWidth: dialogMaxWidth ?? tokens.dialogMaxWidth,
motion: resolvedMotion,
enterCurve: resolvedEnter,
exitCurve: resolvedExit,
radius: tokens.radius,
railWidthOf: resolvedRail,
fadeScale: resolvedFade,
slideUp: resolvedSlide,
phonePlacement: resolvedPlacement,
dismissValue: dismissValue,
useRootNavigator: resolvedRoot,
dismissLabel: resolvedDismissLabel,
closeTooltip: resolvedCloseTooltip,
paintPhoneTitle: paintPhoneTitle,
floatingAppearance: resolvedFloatingAppearance,
child: child,
);
},
transitionBuilder: (ctx, animation, secondaryAnimation, child) => child,
);
}