showFSheet<T> function

Future<T?> showFSheet<T>({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. required FLayout side,
  4. bool useRootNavigator = false,
  5. FSheetStyle? style,
  6. double? mainAxisMaxRatio = 9 / 16,
  7. String? barrierLabel,
  8. bool barrierDismissible = true,
  9. BoxConstraints constraints = const BoxConstraints(),
  10. bool draggable = true,
  11. RouteSettings? routeSettings,
  12. AnimationController? transitionAnimationController,
  13. Offset? anchorPoint,
  14. 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:

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,
    ),
  );
}