showDievasBottomSheet<T> function

Future<T?> showDievasBottomSheet<T>({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. bool isDismissible = true,
  4. bool enableDrag = true,
  5. bool isScrollControlled = false,
  6. bool isExpanded = false,
  7. bool fitContent = false,
  8. bool enableResize = true,
  9. double maxHeightFactor = 0.93,
  10. bool useRootNavigator = false,
  11. bool useSafeArea = true,
  12. double? height,
  13. double? heightFactor,
  14. double? closeProgressThreshold,
  15. Color? backgroundColour,
  16. Color? barrierColour,
  17. BorderRadiusGeometry? borderRadius,
  18. Duration? transitionDuration,
  19. Curve? transitionCurve,
  20. String? semanticLabel,
  21. String? barrierLabel,
  22. RouteSettings? routeSettings,
})

Shows a themed modal sheet and returns the value passed when it closes.

Size it with height, heightFactor, or maxHeightFactor for full sheets; fitContent wraps content up to the cap. enableResize lets upward drags grow it, and lazy lists must set shrinkWrap.

A released drag below closeProgressThreshold or a fast fling closes it; isDismissible gates barrier and Escape dismissal. Nested lists can hand a top-of-list drag to the sheet.

Implementation

Future<T?> showDievasBottomSheet<T>({
  required BuildContext context,
  required WidgetBuilder builder,
  bool isDismissible = true,
  bool enableDrag = true,
  bool isScrollControlled = false,
  bool isExpanded = false,
  bool fitContent = false,
  bool enableResize = true,
  double maxHeightFactor = 0.93,
  bool useRootNavigator = false,
  bool useSafeArea = true,
  double? height,
  double? heightFactor,
  double? closeProgressThreshold,
  Color? backgroundColour,
  Color? barrierColour,
  BorderRadiusGeometry? borderRadius,
  Duration? transitionDuration,
  Curve? transitionCurve,
  String? semanticLabel,
  String? barrierLabel,
  RouteSettings? routeSettings,
}) {
  assert(maxHeightFactor > 0 && maxHeightFactor <= 1);
  assert(height == null || height > 0);
  assert(heightFactor == null || (heightFactor > 0 && heightFactor <= 1));
  assert(height == null || heightFactor == null);
  assert(closeProgressThreshold == null || (closeProgressThreshold > 0 && closeProgressThreshold < 1));
  final data = DievasTheme.of(context);
  final theme = data.components.bottomSheet;
  final navigator = Navigator.of(context, rootNavigator: useRootNavigator);
  return navigator.push<T>(
    _DievasSheetRoute<T>(
      builder: builder,
      data: data,
      themes: InheritedTheme.capture(from: context, to: navigator.context),
      materialTheme: Theme.of(context),
      dismissible: isDismissible,
      enableDrag: enableDrag,
      scrollControlled: isScrollControlled,
      expanded: isExpanded,
      fitContent: fitContent,
      resize: enableResize,
      maxHeightFactor: maxHeightFactor,
      safeArea: useSafeArea,
      height: height,
      heightFactor: heightFactor,
      threshold: closeProgressThreshold ?? theme.closeProgressThreshold,
      background: backgroundColour ?? theme.backgroundColour,
      barrier: barrierColour ?? theme.barrierColour,
      radius: borderRadius ?? theme.borderRadius,
      duration: MediaQuery.disableAnimationsOf(context)
          ? .zero
          : switch ((transitionDuration, theme.transitionDuration)) {
              (final duration?, _) || (_, final duration?) => duration,
              _ => data.animation.standard,
            },
      curve: switch ((transitionCurve, theme.transitionCurve)) {
        (final curve?, _) || (_, final curve?) => curve,
        _ => data.animation.easingEnter,
      },
      label: semanticLabel,
      barrierText: switch (barrierLabel) {
        final label? => label,
        _ => MaterialLocalizations.of(context).modalBarrierDismissLabel,
      },
      settings: routeSettings,
    ),
  );
}