openSheetOverlay<T> function

DrawerOverlayCompleter<T?> openSheetOverlay<T>({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. required OverlayPosition position,
  4. bool barrierDismissible = true,
  5. bool transformBackdrop = false,
  6. WidgetBuilder? backdropBuilder,
  7. Color? barrierColor,
  8. bool draggable = false,
  9. AnimationController? animationController,
  10. bool autoOpen = true,
  11. BoxConstraints? constraints,
  12. AlignmentGeometry? alignment,
})

Opens a sheet overlay with minimal styling and full-screen expansion.

Creates a sheet overlay that slides in from the specified position, typically used for bottom sheets or side panels. Unlike drawers, sheets don't transform the backdrop and have minimal decoration.

Features:

  • Full-screen expansion with edge-to-edge content
  • Minimal styling and decoration
  • Optional drag interaction
  • Safe area integration
  • Barrier dismissal support

Parameters:

  • context (BuildContext, required): build context for overlay creation
  • builder (WidgetBuilder, required): function that builds sheet content
  • position (OverlayPosition, required): side from which sheet slides in
  • barrierDismissible (bool, default: true): whether tapping barrier dismisses sheet
  • transformBackdrop (bool, default: false): whether to transform backdrop
  • backdropBuilder (WidgetBuilder?, optional): custom backdrop builder
  • barrierColor (Color?, optional): color of the modal barrier
  • draggable (bool, default: false): whether sheet can be dragged to dismiss
  • animationController (AnimationController?, optional): custom animation controller
  • autoOpen (bool, default: true): whether to automatically open on creation
  • constraints (BoxConstraints?, optional): size constraints for sheet
  • alignment (AlignmentGeometry?, optional): alignment within constraints

Returns: A DrawerOverlayCompleter that provides control over the sheet lifecycle.

Example:

final completer = openSheetOverlay<bool>(
  context: context,
  position: OverlayPosition.bottom,
  builder: (context) => BottomSheetContent(),
  draggable: true,
);

Implementation

DrawerOverlayCompleter<T?> openSheetOverlay<T>({
  required BuildContext context,
  required WidgetBuilder builder,
  required OverlayPosition position,
  bool barrierDismissible = true,
  bool transformBackdrop = false,
  WidgetBuilder? backdropBuilder,
  Color? barrierColor,
  bool draggable = false,
  AnimationController? animationController,
  bool autoOpen = true,
  BoxConstraints? constraints,
  AlignmentGeometry? alignment,
}) {
  final theme = ComponentTheme.maybeOf<DrawerTheme>(context);
  barrierColor ??= theme?.barrierColor;
  return openRawDrawer<T>(
    context: context,
    transformBackdrop: transformBackdrop,
    barrierDismissible: barrierDismissible,
    useSafeArea: false, // handled by the sheet itself
    animationController: animationController,
    backdropBuilder: backdropBuilder,
    autoOpen: autoOpen,
    constraints: constraints,
    alignment: alignment,
    builder: (context, extraSize, size, padding, stackIndex) {
      return SheetWrapper(
        position: position,
        expands: true,
        draggable: draggable,
        extraSize: extraSize,
        size: size,
        padding: padding,
        barrierColor: barrierColor,
        stackIndex: stackIndex,
        child: Builder(builder: (context) {
          return builder(context);
        }),
      );
    },
    position: position,
  );
}