showFSheet<T> function
- required BuildContext context,
- required WidgetBuilder builder,
- required FLayout side,
- FSheetStyle? style,
- double? mainAxisMaxRatio = 9 / 16,
- String? barrierLabel,
- bool barrierDismissible = true,
- BoxConstraints constraints = const BoxConstraints(),
- bool draggable = true,
- RouteSettings? routeSettings,
- AnimationController? transitionAnimationController,
- Offset? anchorPoint,
- bool useSafeArea = false,
Shows a modal sheet that appears from the given side
.
A modal sheet is an alternative to a menu or a dialog and prevents the user from interacting with the rest of the app.
context
is used to look up the Navigator and FSheetStyle for the sheet. It is only used when the method is
called. Its corresponding widget can be safely removed from the tree before the sheet is closed.
useRootNavigator
ensures that the root navigator displays the sheet whentrue
. This is useful in the case that a
modal sheet needs to be displayed above all other content but the caller is inside another Navigator.
style
defaults to FSheetStyle from the closest FTheme ancestor.
mainAxisMaxRatio
represents the main axis's max constraint ratio for the sheet, depending on side
.
Defaults to 9 / 16. The main axis is the width if side
is FLayout.ltr or FLayout.rtl, and the height if side
is FLayout.ttb or FLayout.btt. Consider setting mainAxisMaxRatio
to null if this sheet has a scrollable child,
i.e. ListView, along the main axis, to have the sheet be draggable.
barrierLabel
defaults to FLocalizations.barrierLabel.
Returns a Future
that resolves to the value (if any) that was passed to Navigator.pop when the modal sheet was
closed.
See:
- https://forui.dev/docs/overlay/sheet for working examples.
- showFPersistentSheet for displaying a sheet above the current widget.
- FModalSheetRoute for more information about the various arguments.
- FSheetStyle for customizing a switch's appearance.
- DraggableScrollableSheet, creates a bottom sheet that grows and then becomes scrollable once it reaches its maximum size.
Implementation
Future<T?> showFSheet<T>({
required BuildContext context,
required WidgetBuilder builder,
required FLayout side,
bool useRootNavigator = false,
FSheetStyle? style,
double? mainAxisMaxRatio = 9 / 16,
String? barrierLabel,
bool barrierDismissible = true,
BoxConstraints constraints = const BoxConstraints(),
bool draggable = true,
RouteSettings? routeSettings,
AnimationController? transitionAnimationController,
Offset? anchorPoint,
bool useSafeArea = false,
}) {
assert(debugCheckHasMediaQuery(context), '');
final navigator = Navigator.of(context, rootNavigator: useRootNavigator);
final localizations = FLocalizations.of(context) ?? FDefaultLocalizations();
return navigator.push(
FModalSheetRoute<T>(
style: style ?? context.theme.sheetStyle,
side: side,
builder: builder,
mainAxisMaxRatio: mainAxisMaxRatio,
capturedThemes: InheritedTheme.capture(from: context, to: navigator.context),
barrierOnTapHint: localizations.barrierOnTapHint(localizations.sheetLabel),
barrierLabel: barrierLabel ?? localizations.barrierLabel,
barrierDismissible: barrierDismissible,
barrierColor: (style ?? context.theme.sheetStyle).barrierColor,
constraints: constraints,
draggable: draggable,
settings: routeSettings,
transitionAnimationController: transitionAnimationController,
anchorPoint: anchorPoint,
useSafeArea: useSafeArea,
),
);
}