openDrawerOverlay<T> function
DrawerOverlayCompleter<T?>
openDrawerOverlay<T>({
- required BuildContext context,
- required WidgetBuilder builder,
- required OverlayPosition position,
- bool expands = false,
- bool draggable = true,
- bool barrierDismissible = true,
- WidgetBuilder? backdropBuilder,
- bool useSafeArea = true,
- bool? showDragHandle,
- BorderRadiusGeometry? borderRadius,
- Size? dragHandleSize,
- bool transformBackdrop = true,
- double? surfaceOpacity,
- double? surfaceBlur,
- Color? barrierColor,
- AnimationController? animationController,
- bool autoOpen = true,
- BoxConstraints? constraints,
- AlignmentGeometry? alignment,
Opens a drawer overlay with comprehensive customization options.
Creates a modal drawer that slides in from the specified position with draggable interaction, backdrop transformation, and proper theme integration. Returns a completer that can be used to control the drawer lifecycle.
Features:
- Configurable slide-in positions (left, right, top, bottom)
- Draggable interaction with gesture support
- Backdrop transformation and scaling effects
- Safe area handling and proper theming
- Dismissible barriers and custom backdrop builders
Parameters:
context(BuildContext, required): build context for overlay creationbuilder(WidgetBuilder, required): function that builds drawer contentposition(OverlayPosition, required): side from which drawer slides inexpands(bool, default: false): whether drawer should expand to fill available spacedraggable(bool, default: true): whether drawer can be dragged to dismissbarrierDismissible(bool, default: true): whether tapping barrier dismisses drawerbackdropBuilder(WidgetBuilder?, optional): custom backdrop builderuseSafeArea(bool, default: true): whether to respect device safe areasshowDragHandle(bool?, optional): whether to show drag handleborderRadius(BorderRadiusGeometry?, optional): corner radius for drawerdragHandleSize(Size?, optional): size of the drag handletransformBackdrop(bool, default: true): whether to scale backdropsurfaceOpacity(double?, optional): opacity for surface effectssurfaceBlur(double?, optional): blur intensity for surface effectsbarrierColor(Color?, optional): color of the modal barrieranimationController(AnimationController?, optional): custom animation controllerautoOpen(bool, default: true): whether to automatically open on creationconstraints(BoxConstraints?, optional): size constraints for draweralignment(AlignmentGeometry?, optional): alignment within constraints
Returns: A DrawerOverlayCompleter that provides control over the drawer lifecycle.
Example:
final completer = openDrawerOverlay<String>(
context: context,
position: OverlayPosition.left,
builder: (context) => DrawerContent(),
draggable: true,
barrierDismissible: true,
);
final result = await completer.future;
Implementation
DrawerOverlayCompleter<T?> openDrawerOverlay<T>({
required BuildContext context,
required WidgetBuilder builder,
required OverlayPosition position,
bool expands = false,
bool draggable = true,
bool barrierDismissible = true,
WidgetBuilder? backdropBuilder,
bool useSafeArea = true,
bool? showDragHandle,
BorderRadiusGeometry? borderRadius,
Size? dragHandleSize,
bool transformBackdrop = true,
double? surfaceOpacity,
double? surfaceBlur,
Color? barrierColor,
AnimationController? animationController,
bool autoOpen = true,
BoxConstraints? constraints,
AlignmentGeometry? alignment,
}) {
final theme = ComponentTheme.maybeOf<DrawerTheme>(context);
showDragHandle ??= theme?.showDragHandle ?? true;
surfaceOpacity ??= theme?.surfaceOpacity;
surfaceBlur ??= theme?.surfaceBlur;
barrierColor ??= theme?.barrierColor;
dragHandleSize ??= theme?.dragHandleSize;
return openRawDrawer<T>(
context: context,
barrierDismissible: barrierDismissible,
backdropBuilder: backdropBuilder,
useSafeArea: useSafeArea,
transformBackdrop: transformBackdrop,
animationController: animationController,
autoOpen: autoOpen,
constraints: constraints,
alignment: alignment,
builder: (context, extraSize, size, padding, stackIndex) {
return DrawerWrapper(
position: position,
expands: expands,
draggable: draggable,
extraSize: extraSize,
size: size,
showDragHandle: showDragHandle ?? true,
dragHandleSize: dragHandleSize,
padding: padding,
borderRadius: borderRadius,
surfaceOpacity: surfaceOpacity,
surfaceBlur: surfaceBlur,
barrierColor: barrierColor,
stackIndex: stackIndex,
child: Builder(builder: (context) {
return builder(context);
}),
);
},
position: position,
);
}