bottomSheet<T> static method

Future<T?> bottomSheet<T>(
  1. Widget child, {
  2. bool isScrollControlled = true,
  3. bool useSafeArea = true,
  4. bool isDismissible = true,
  5. bool enableDrag = true,
  6. bool showDragHandle = false,
  7. bool useRootNavigator = true,
  8. double? elevation,
  9. Color? backgroundColor,
  10. Color? barrierColor,
  11. ShapeBorder? shape,
  12. Clip? clipBehavior,
  13. BoxConstraints? constraints,
  14. VoidCallback? onDismiss,
})

Implementation

static Future<T?> bottomSheet<T>(
  Widget child, {
  bool isScrollControlled = true,
  bool useSafeArea = true,
  bool isDismissible = true,
  bool enableDrag = true,
  bool showDragHandle = false,
  bool useRootNavigator = true,
  double? elevation,
  Color? backgroundColor,
  Color? barrierColor,
  ShapeBorder? shape,
  Clip? clipBehavior,
  BoxConstraints? constraints,
  VoidCallback? onDismiss,
}) {
  final Future<T?> sheetFuture = showModalBottomSheet<T>(
    context: navigatorKey.currentContext!,
    isScrollControlled: isScrollControlled,
    useSafeArea: useSafeArea,
    isDismissible: isDismissible,
    enableDrag: enableDrag,
    showDragHandle: showDragHandle,
    useRootNavigator: useRootNavigator,
    backgroundColor: backgroundColor ?? Theme.of(navigatorKey.currentContext!).canvasColor,
    barrierColor: barrierColor,
    elevation: elevation,
    shape:
        shape ??
        const RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
        ),
    clipBehavior: clipBehavior ?? Clip.antiAlias,
    constraints: constraints,
    builder: (BuildContext context) => Padding(
      padding: EdgeInsets.only(
        bottom: MediaQuery.of(navigatorKey.currentContext!).viewInsets.bottom,
      ),
      child: child,
    ),
  );

  return sheetFuture.then((T? value) {
    onDismiss?.call();
    return value;
  });
}