show<T> static method
Future<T?>
show<T>(
- BuildContext context, {
- required String title,
- required List<
Widget> builder(- BuildContext context
- List<
Widget> foot(- BuildContext context
- bool close = true,
Raises a transient sheet over the whole app (the app's root
navigator, Fluent2Host.navigatorOf): a Fluent2SheetShell headed by
title, holding builder's parts and foot's acts. Completes with
the value the sheet pops with: null when it is dismissed.
On a phone it is ui_core's bottom sheet (DesignBottomSheetRoute): it
rises on a spring, rides above the keyboard, follows a drag (its parts,
scrolled to their top, hand the drag on) and closes when let go low or
flung down. On a wide window it is ui_core's dialog route, centred and
fading. Focus goes back to what raised it as it closes.
Implementation
static Future<T?> show<T>(
BuildContext context, {
required String title,
required List<Widget> Function(BuildContext context) builder,
List<Widget> Function(BuildContext context)? foot,
bool close = true,
}) {
final t = context.fluent2Theme;
final navigator = Fluent2Host.navigatorOf(context);
final themes = InheritedTheme.capture(from: context, to: navigator.context);
final most = maxHeight(context);
Widget shell(BuildContext sheetContext) => RoutePresentationScope(
presentation: RoutePresentation.sheet,
child: Fluent2SheetShell(
title: title,
close: close,
safe: true,
foot: foot?.call(sheetContext) ?? const [],
children: builder(sheetContext),
),
);
if (Fluent2Layout.isWide(context)) {
return navigator.push(
DesignDialogRoute<T>(
barrierDismissible: true,
barrierLabel: DesignLocalizations.of(context)
.modalBarrierDismissLabel,
barrierColor: t.overlay,
semanticLabel: title,
dampingRatio: Fluent2Motion.springDamping,
stiffness: Fluent2Motion.springGentle,
builder: (sheetContext, details) => themes.wrap(
fluent2Fade(
details.animation,
Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: Fluent2ChromeMetrics.dialogWidth,
maxHeight: most,
),
child: shell(sheetContext),
),
),
),
),
),
);
}
return navigator.push(
DesignBottomSheetRoute<T>(
barrierLabel: DesignLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: t.overlay,
semanticLabel: title,
dampingRatio: Fluent2Motion.springDamping,
stiffness: Fluent2Motion.springGentle,
// A tablet's sheet stands no wider than the desktop's dialog, as
// showFluent2BottomSheet's, centred over the window's foot.
builder: (sheetContext, details) => themes.wrap(
fluent2BottomSheetPlace(
maxHeight: most,
child: PrimaryScrollController(
controller: details.scrollController,
child: shell(sheetContext),
),
),
),
),
);
}