showFlexibleBottomSheet<T> function

Future<T?> showFlexibleBottomSheet<T>({
  1. required BuildContext context,
  2. required FlexibleDraggableScrollableWidgetBuilder builder,
  3. DraggableScrollableController? draggableScrollableController,
  4. double? minHeight,
  5. double? initHeight,
  6. double? maxHeight,
  7. bool isCollapsible = true,
  8. bool isDismissible = true,
  9. bool isExpand = true,
  10. bool useRootNavigator = false,
  11. bool isModal = true,
  12. List<double>? anchors,
  13. Color? keyboardBarrierColor,
  14. Color? bottomSheetColor,
  15. BorderRadiusGeometry? bottomSheetBorderRadius,
  16. Color? barrierColor,
  17. Duration? duration,
  18. bool isSafeArea = false,
  19. BoxDecoration? decoration,
  20. bool useRootScaffold = true,
})

Shows a flexible bottom sheet.

builder - must return a scrollable widget and you must to pass the scrollController provided by the builder to your scrollable widget. draggableScrollableController that allow programmatically control bottom sheet. minHeight - min height in fractional value for bottom sheet. e.g. 0.1. initHeight - init height in fractional value for bottom sheet. e.g. 0.5. maxHeight - init height in fractional value for bottom sheet. e.g. 0.5. isCollapsible - will the bottom sheet collapse. isDismissible - the bottom sheet will be dismissed when user taps on the scrim. isExpand - should your bottom sheet expand. By default, isExpand is true, which means that the bottom sheet will have the height you specify (initHeight and maxHeight) regardless of the height of the content in it. If isExpand is false, maxHeight and initHeight must be equal, in which case the bottom sheet will calculate its height based on the content, but no more than maxHeight and initHeight. isModal - if true, overlay background with dark color. anchors - list of sizes in fractional value that the bottom sheet can accept. keyboardBarrierColor - keyboard color. bottomSheetBorderRadius - bottom sheet border radius. bottomSheetColor - bottom sheet color. barrierColor - barrier color. duration - animation speed when opening bottom sheet. isSafeArea - should the bottom sheet provide a SafeArea, false by default. decoration - content decoration bottom sheet. useRootScaffold - if true, add Scaffold widget on widget tree. Default true.

Implementation

Future<T?> showFlexibleBottomSheet<T>({
  required BuildContext context,
  required FlexibleDraggableScrollableWidgetBuilder builder,
  DraggableScrollableController? draggableScrollableController,
  double? minHeight,
  double? initHeight,
  double? maxHeight,
  bool isCollapsible = true,
  bool isDismissible = true,
  bool isExpand = true,
  bool useRootNavigator = false,
  bool isModal = true,
  List<double>? anchors,
  Color? keyboardBarrierColor,
  Color? bottomSheetColor,
  BorderRadiusGeometry? bottomSheetBorderRadius,
  Color? barrierColor,
  Duration? duration,
  bool isSafeArea = false,
  BoxDecoration? decoration,
  bool useRootScaffold = true,
}) {
  assert(debugCheckHasMediaQuery(context));
  assert(debugCheckHasMaterialLocalizations(context));
  assert(barrierColor == null || isModal);

  return Navigator.of(context, rootNavigator: useRootNavigator).push(
    FlexibleBottomSheetRoute<T>(
      theme: Theme.of(context),
      barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
      draggableScrollableController: draggableScrollableController,
      minHeight: minHeight ?? 0,
      initHeight: initHeight ?? 0.5,
      maxHeight: maxHeight ?? 1,
      isCollapsible: isCollapsible,
      isDismissible: isDismissible,
      isExpand: isExpand,
      builder: builder,
      isModal: isModal,
      anchors: anchors,
      keyboardBarrierColor: keyboardBarrierColor,
      bottomSheetColor: bottomSheetColor,
      bottomSheetBorderRadius: bottomSheetBorderRadius,
      barrierBottomSheetColor: barrierColor,
      duration: duration,
      isSafeArea: isSafeArea,
      decoration: decoration,
      useRootScaffold: useRootScaffold,
    ),
  );
}