confirmAction function
void
confirmAction(
- BuildContext context, {
- dynamic onConfirm()?,
- String? message,
- String? confirm,
- ElevatedButton? actionButtonStyle,
- ButtonStyle? confirmButtonStyle,
- ButtonStyle? closeButtonStyle,
- dynamic onClose()?,
- String? close,
- Key? confirmKey,
- bool? useRedColor,
- String? title,
- Widget? closeWidget,
- Widget? confirmWidget,
- Widget? messageWidget,
- Widget? titleWidget,
Implementation
void confirmAction(
BuildContext context, {
Function()? onConfirm,
String? message,
String? confirm,
ElevatedButton? actionButtonStyle,
ButtonStyle? confirmButtonStyle,
ButtonStyle? closeButtonStyle,
Function()? onClose,
String? close,
Key? confirmKey,
bool? useRedColor,
String? title,
Widget? closeWidget,
Widget? confirmWidget,
Widget? messageWidget,
Widget? titleWidget,
}) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: titleWidget != null
? titleWidget
: Text(title ?? "Are you sure you can to continue"),
content: messageWidget != null
? messageWidget
: message == null
? null
: Text(message),
actions: [
if (confirmWidget != null)
confirmWidget
else
Container(
width: width(context),
padding: const EdgeInsets.all(10),
child: actionButtonStyle ??
ElevatedButton(
key: confirmKey ?? const Key("yes"),
style: confirmButtonStyle ??
ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () {
pop(context);
onConfirm!();
},
child: Text(confirm ?? "Yes"),
),
),
if (closeWidget != null)
closeWidget
else
Container(
width: width(context),
padding: const EdgeInsets.all(10),
child: ElevatedButton(
key: const Key("no"),
style: closeButtonStyle,
onPressed: () {
if (onClose != null) {
onClose();
}
pop(context);
},
child: Text(close ?? "No"),
),
),
],
),
);
}