openConfirmSheet static method

void openConfirmSheet(
  1. BuildContext context, {
  2. required Widget body,
  3. void onClose(
    1. dynamic value
    )?,
  4. bool? expand,
  5. double? initialChildSize,
  6. double? minChildSize,
  7. double? maxChildSize,
  8. bool? scrollable,
  9. Color? backgroundColor,
  10. Color? handleColor,
  11. Color? buttonColor,
  12. Color? buttonTextColor,
  13. EdgeInsetsGeometry? padding,
  14. double? buttonSpacing,
})

Implementation

static void openConfirmSheet(
  BuildContext context, {
  required Widget body,
  void Function(dynamic value)? onClose,
  bool? expand,
  double? initialChildSize,
  double? minChildSize,
  double? maxChildSize,
  bool? scrollable,
  Color? backgroundColor,
  Color? handleColor,
  Color? buttonColor,
  Color? buttonTextColor,
  EdgeInsetsGeometry? padding,
  double? buttonSpacing,
}) {
  OpenCustomSheet(
    scrollable: scrollable,
    expand: expand,
    initialChildSize: initialChildSize,
    minChildSize: minChildSize,
    maxChildSize: maxChildSize,
    onClose: onClose,
    body: ({scrollController}) => Container(
      decoration: BoxDecoration(
        borderRadius:
            const BorderRadiusDirectional.vertical(top: Radius.circular(10)),
        color: backgroundColor ?? Theme.of(context).cardColor,
      ),
      padding: padding ?? const EdgeInsets.only(bottom: 16.0),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Center(
            child: Container(
              width: 150,
              height: 5,
              decoration: BoxDecoration(
                  color: handleColor ?? CupertinoColors.inactiveGray,
                  borderRadius: BorderRadius.circular(20)),
              margin: const EdgeInsets.all(10),
            ),
          ),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
            child: Center(child: body),
          ),
          DoubleListTileButtons(
            padding: padding ??
                const EdgeInsets.symmetric(vertical: 10, horizontal: 16.0),
            space: buttonSpacing ?? 16.0,
            firstButton: ListTileButton(
              onPressed: () => Navigator.pop(context, false),
              backgroundColor: buttonColor ?? Theme.of(context).cardColor,
              body: FittedBox(
                fit: BoxFit.scaleDown,
                child: Text(
                  'Close', // Replaced `tr('chiudi')` with a static string or you can handle localization separately.
                  style: Theme.of(context)
                      .textTheme
                      .labelLarge!
                      .copyWith(color: buttonTextColor ?? Colors.white),
                  textAlign: TextAlign.center,
                ),
              ),
            ),
            secondButton: ListTileButton(
              onPressed: () => Navigator.pop(context, true),
              backgroundColor: buttonColor ?? Theme.of(context).primaryColor,
              body: FittedBox(
                fit: BoxFit.scaleDown,
                child: Text(
                  'Confirm', // Replaced `tr('conferma')` with a static string or you can handle localization separately.
                  style: Theme.of(context)
                      .textTheme
                      .labelLarge!
                      .copyWith(color: buttonTextColor ?? Colors.white),
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
        ],
      ),
    ),
  ).show(context);
}