showCustomDialog function

Future<void> showCustomDialog(
  1. BuildContext context, {
  2. Widget? content,
  3. required AppTheme theme,
  4. bool dismissible = true,
  5. String? positiveText,
  6. String? negativeText,
  7. Color? barrierColor = Colors.black54,
  8. Color? backgroundColor = Colors.white,
  9. Color color = Colors.black,
  10. Color textColor = Colors.white,
  11. Color? negativeColor,
  12. Color? positiveColor,
  13. void onNegativePressed()?,
  14. void onPositivePressed()?,
})

Shows a customizable dialog with positive and negative actions.

content is the main body widget. theme controls styling. Optional parameters allow customizing button text and behavior.

Implementation

Future<void> showCustomDialog(
  BuildContext context, {
  Widget? content,
  required AppTheme theme,
  bool dismissible = true,
  String? positiveText,
  String? negativeText,
  Color? barrierColor = Colors.black54,
  Color? backgroundColor = Colors.white,
  Color color = Colors.black,
  Color textColor = Colors.white,
  Color? negativeColor,
  Color? positiveColor,
  void Function()? onNegativePressed,
  void Function()? onPositivePressed,
}) {
  return baseDialog(
    context,
    barrierColor: barrierColor,
    backgroundColor: backgroundColor,
    content: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        content ?? const SizedBox(),
        const SizedBox(height: 20),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (negativeText != null)
              Container(
                constraints: const BoxConstraints(maxWidth: 110, minWidth: 110),
                child: _button(
                  color: negativeColor ?? theme.primaryColor(),
                  text: negativeText,
                  onPressed: () {
                    hideDialog(context);
                    onNegativePressed?.call();
                  },
                ),
              ),
            if (negativeText != null || positiveText != null) const SizedBox(width: 12),
            if (positiveText != null)
              Container(
                constraints: const BoxConstraints(maxWidth: 110, minWidth: 110),
                child: _button(
                  color: positiveColor ?? theme.primaryColor(),
                  text: positiveText,
                  onPressed: () {
                    hideDialog(context);
                    onPositivePressed?.call();
                  },
                ),
              ),
          ],
        ),
      ],
    ),
  );
}