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,
- bool confirm = false,
Raises a transient sheet over the whole app (the app's root navigator,
LedgerHost.navigatorOf): an LedgerSheetShell headed by title,
holding builder's parts and foot's acts. confirm marks a question
its foot's acts answer (Freeze your card?), which at desktop width
stands narrower than a task's. Completes with the value the sheet pops
with: null when it is dismissed (the close, a drag down, the scrim).
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,
bool confirm = false,
}) {
final t = context.ledgerTheme;
final navigator = LedgerHost.navigatorOf(context);
// As showModalBottomSheet does: the caller's themes ride along.
final themes = InheritedTheme.capture(from: context, to: navigator.context);
final most = maxHeight(context);
Widget shell(BuildContext sheetContext) => RoutePresentationScope(
presentation: RoutePresentation.sheet,
child: LedgerSheetShell(
title: title,
showClose: close,
useSafeArea: true,
foot: foot?.call(sheetContext) ?? const [],
children: builder(sheetContext),
),
);
if (LedgerLayout.isWide(context)) {
return navigator.push(
DesignDialogRoute<T>(
barrierDismissible: true,
barrierColor: t.overlay,
semanticLabel: title,
builder: (sheetContext, details) => themes.wrap(
FadeTransition(
opacity: details.animation.drive(ledgerPresence),
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: dialogWidth(confirm: confirm),
maxHeight: most,
),
child: shell(sheetContext),
),
),
),
),
),
);
}
return navigator.push(
DesignBottomSheetRoute<T>(
barrierColor: t.overlay,
semanticLabel: title,
// The keyboard rides outside the card (ui_core stands the sheet on
// it): the card keeps its geometry and simply sits higher.
builder: (sheetContext, details) =>
themes.wrap(_SheetMeasure(most: most, child: shell(sheetContext))),
),
);
}