showCloseAlertDialog function

Future<bool> showCloseAlertDialog({
  1. required CloseAlertStyle style,
  2. required BuildContext context,
})

Implementation

Future<bool> showCloseAlertDialog({
  required CloseAlertStyle style,
  required BuildContext context,
}) async {
  bool isClose = false;
  await showDialog(
    barrierColor: Colors.black.withOpacity(0.4),
    context: context,
    builder: (BuildContext context) => AlertDialog(
      backgroundColor: Colors.transparent,
      content: Container(
        decoration: style.containerDecoration,
        padding: const EdgeInsets.only(top: 10, bottom: 6, left: 8, right: 8),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Text(
              style.title,
              style: style.titleTextStyle,
            ),
            const SizedBox(height: 10),
            Text(
              style.message,
              style: style.messageTextStyle,
            ),
            const SizedBox(height: 10),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 4),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  TextButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                    child: Text(
                      style.negativeButtonText,
                      style: style.negativeButtonTextStyle,
                    ),
                  ),
                  TextButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                      Navigator.of(context).pop();
                      isClose = true;
                    },
                    child: Text(
                      style.positiveButtonText,
                      style: style.positiveButtonTextStyle,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ),
  );
  return isClose;
}