showCustomDialog function
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 onNegativePressed()?,
- 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();
},
),
),
],
),
],
),
);
}