ConfirmAlertBox constructor
ConfirmAlertBox({
- BuildContext? context,
- String? title,
- String? infoMessage,
- Color? titleTextColor,
- Color? messageTextColor,
- Color? buttonColorForYes,
- String? buttonTextForYes,
- Color? buttonTextColorForYes,
- Color? buttonColorForNo,
- Color? buttonTextColorForNo,
- String? buttonTextForNo,
- Function? onPressedYes,
- Function? onPressedNo,
- IconData? icon,
Implementation
ConfirmAlertBox(
{this.context,
this.title,
this.infoMessage,
this.titleTextColor,
this.messageTextColor,
this.buttonColorForYes,
this.buttonTextForYes,
this.buttonTextColorForYes,
this.buttonColorForNo,
this.buttonTextColorForNo,
this.buttonTextForNo,
this.onPressedYes,
this.onPressedNo,
this.icon}) {
showDialog(
barrierDismissible: false,
context: context!,
builder: (BuildContext context) {
return SimpleDialog(
title: Row(
children: <Widget>[
Icon(
icon ?? Icons.help,
color: titleTextColor,
),
SizedBox(
width: 4.0,
),
Flexible(
child: Text(
title ?? "Your alert title",
style: TextStyle(
fontWeight: FontWeight.w600,
color: titleTextColor ?? Color(0xFF4E4E4E)),
),
)
],
),
contentPadding: const EdgeInsets.fromLTRB(24, 12, 24, 12),
children: <Widget>[
Text(
infoMessage ?? "Alert message here",
style: TextStyle(color: messageTextColor),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
buttonColorForYes ?? Colors.green),
),
onPressed: onPressedYes as void Function()? ?? () {},
child: Text(
buttonTextForYes ?? "Yes",
style: TextStyle(
color: buttonTextColorForYes ?? Colors.white),
),
),
SizedBox(
width: 4,
),
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
buttonColorForNo ?? Colors.red),
),
onPressed: onPressedNo as void Function()? ??
() {
Navigator.of(context).pop();
},
child: Text(
buttonTextForNo ?? "No",
style: TextStyle(
color: buttonTextColorForNo ?? Colors.white),
),
)
],
)
],
);
});
}