showDoubleSheet<T> function

Future<T?> showDoubleSheet<T>({
  1. required BuildContext context,
  2. required String title,
  3. required Widget child,
  4. Widget? titleWidget,
  5. Widget? customHeaderWidget,
  6. double initialChildSize = 0.4,
  7. double minChildSize = 0.25,
  8. double maxChildSize = 0.9,
  9. Color? backgroundColor,
  10. Color? headerBackgroundColor,
  11. TextStyle? titleStyle,
  12. bool enableDrag = true,
  13. bool isDismissible = true,
  14. bool showDragHandle = true,
  15. bool allowFullScreen = false,
  16. BorderRadius? borderRadius,
  17. BorderRadius? headerRadius,
  18. bool enableSynchronizedScrolling = false,
})

Implementation

Future<T?> showDoubleSheet<T>({
  required BuildContext context,
  required String title,
  required Widget child,
  Widget? titleWidget,
  Widget? customHeaderWidget,
  double initialChildSize = 0.4,
  double minChildSize = 0.25,
  double maxChildSize = 0.9,
  Color? backgroundColor,
  Color? headerBackgroundColor,
  TextStyle? titleStyle,
  bool enableDrag = true,
  bool isDismissible = true,
  bool showDragHandle = true,
  bool allowFullScreen = false,
  BorderRadius? borderRadius,
  BorderRadius? headerRadius,
  bool enableSynchronizedScrolling = false,
}) {
  final config = DoubleSheetConfig(
    title: title,
    titleWidget: titleWidget,
    customHeaderWidget: customHeaderWidget,
    initialChildSize: initialChildSize,
    minChildSize: minChildSize,
    maxChildSize: maxChildSize,
    backgroundColor: backgroundColor,
    headerBackgroundColor: headerBackgroundColor,
    titleStyle: titleStyle,
    enableDrag: enableDrag,
    isDismissible: isDismissible,
    showDragHandle: showDragHandle,
    allowFullScreen: allowFullScreen,
    borderRadius: borderRadius,
    headerRadius: headerRadius,
    enableSynchronizedScrolling: enableSynchronizedScrolling,
  );

  return showGeneralDialog<T>(
    context: context,
    barrierDismissible: isDismissible,
    barrierLabel:
        isDismissible
            ? MaterialLocalizations.of(context).modalBarrierDismissLabel
            : null,
    barrierColor: Colors.black.withValues(alpha: 0.5),
    transitionDuration: const Duration(milliseconds: 300),
    pageBuilder: (dialogContext, animation, secondaryAnimation) {
      return PopScope(
        canPop: true,
        child: MediaQuery.removeViewInsets(
          context: dialogContext,
          removeTop: true,
          child: SynchronizedDoubleSheet(
            config: config,
            animation: animation,
            onClose: () {
              if (Navigator.of(dialogContext).canPop()) {
                Navigator.of(dialogContext, rootNavigator: false).pop();
              }
            },
            child: child,
          ),
        ),
      );
    },
    transitionBuilder: (context, animation, secondaryAnimation, child) {
      return child;
    },
  );
}