confirmation static method
dynamic
confirmation({
- required BuildContext context,
- required ModalTitle title,
- required String message,
- ModalButton? confirmButton,
- ModalButton? cancelButton,
Shows a dialog with a title, a message and two buttons.
The buttons are labeled "Yes" and "No" by default, but you can change
them by passing the yesButtonText
and noButtonText
parameters.
Implementation
static confirmation({
required BuildContext context,
required ModalTitle title,
required String message,
ModalButton? confirmButton,
ModalButton? cancelButton,
}) {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return _BaseAlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(
color: Colors.transparent,
height: 18,
),
Align(
alignment: Alignment.center,
child: Text(
title.text,
textAlign: TextAlign.center,
style: TextStyle(
color: title.color ?? const Color(0xFF303F9F),
fontWeight: FontWeight.w500,
fontSize: 20,
),
),
),
const Divider(
color: Color(0xFFDBDDE0),
height: 36,
),
Align(
alignment: Alignment.center,
child: Text(
message,
textAlign: TextAlign.center,
style: const TextStyle(
color: Color(0xFF52575C),
fontWeight: FontWeight.w500,
fontSize: 14,
),
),
),
const Divider(
color: Color(0xFFDBDDE0),
height: 36,
),
Align(
alignment: Alignment.center,
child: Row(
children: [
Flexible(
child: ElevatedButton(
onPressed: () => Navigator.pop(context, true),
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
confirmButton?.color ?? const Color(0xFF28A745),
),
minimumSize: const MaterialStatePropertyAll(
Size(double.infinity, 35),
),
shape: const MaterialStatePropertyAll<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(6),
),
),
),
),
child: Text(
confirmButton?.text ?? "Yes",
style: TextStyle(
color: cancelButton?.textColor ??
const Color(0xFFEFF4FF),
fontWeight: FontWeight.bold,
),
),
),
),
const VerticalDivider(
color: Colors.transparent,
width: 15,
),
Flexible(
child: ElevatedButton(
onPressed: () => Navigator.pop(context, false),
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
cancelButton?.color ?? const Color(0xFFDC3545),
),
minimumSize: const MaterialStatePropertyAll(
Size(double.infinity, 35),
),
shape: const MaterialStatePropertyAll<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(6),
),
),
),
),
child: Text(
cancelButton?.text ?? "No",
style: TextStyle(
color: cancelButton?.textColor ??
const Color(0xFFEFF4FF),
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
],
),
);
},
);
}