ConfirmAlertBox constructor

ConfirmAlertBox({
  1. BuildContext? context,
  2. String? title,
  3. String? infoMessage,
  4. Color? titleTextColor,
  5. Color? messageTextColor,
  6. Color? buttonColorForYes,
  7. String? buttonTextForYes,
  8. Color? buttonTextColorForYes,
  9. Color? buttonColorForNo,
  10. Color? buttonTextColorForNo,
  11. String? buttonTextForNo,
  12. Function? onPressedYes,
  13. Function? onPressedNo,
  14. 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),
                  ),
                )
              ],
            )
          ],
        );
      });
}