openDrawer<T> function

Future<T?> openDrawer<T>({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. required OverlayPosition position,
  4. bool expands = false,
  5. bool draggable = true,
  6. bool barrierDismissible = true,
  7. WidgetBuilder? backdropBuilder,
  8. bool useSafeArea = true,
  9. bool? showDragHandle,
  10. BorderRadiusGeometry? borderRadius,
  11. Size? dragHandleSize,
  12. bool transformBackdrop = true,
  13. double? surfaceOpacity,
  14. double? surfaceBlur,
  15. Color? barrierColor,
  16. AnimationController? animationController,
  17. BoxConstraints? constraints,
  18. AlignmentGeometry? alignment,
})

Opens a drawer and returns a future that completes when dismissed.

Convenience function that opens a drawer overlay and returns the future directly, suitable for use with async/await patterns.

Returns: A Future that completes with the result when the drawer is dismissed.

Example:

final result = await openDrawer<String>(
  context: context,
  position: OverlayPosition.left,
  builder: (context) => MyDrawerContent(),
);

Implementation

Future<T?> openDrawer<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,
  BoxConstraints? constraints,
  AlignmentGeometry? alignment,
}) {
  return openDrawerOverlay<T>(
    context: context,
    builder: builder,
    position: position,
    expands: expands,
    draggable: draggable,
    barrierDismissible: barrierDismissible,
    backdropBuilder: backdropBuilder,
    useSafeArea: useSafeArea,
    showDragHandle: showDragHandle,
    borderRadius: borderRadius,
    dragHandleSize: dragHandleSize,
    transformBackdrop: transformBackdrop,
    surfaceOpacity: surfaceOpacity,
    surfaceBlur: surfaceBlur,
    barrierColor: barrierColor,
    animationController: animationController,
    constraints: constraints,
    alignment: alignment,
  ).future;
}