0

I have a class that returns a button to delete a post and i added coolalert package for confirmation popup, but everytime i click on 'Yes" it pops all my home page instead of the popup and the popup dialog still remains on screen. Is there something wrong with my code?

Here is the button class code:

class delButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        alignment: Alignment.topRight,
        child: IconButton(
            onPressed: () async {
              CoolAlert.show(
                context: context,
                type: CoolAlertType.confirm,
                text: 'Do you want to delete this post?',
                confirmBtnText: 'Yes',
                cancelBtnText: 'No',
                confirmBtnColor: Colors.green,
                onConfirmBtnTap: () {
                  bool response = await repository
                      .deleteData(listBlog[index].id);
                  if (response) {
                    print('Delete Data Success!');
                  } else {
                    print('Delete Data Fail!');
                  }
                  getData();
                  Navigator.of(context).pop();
                },
              );
            },
            icon: Icon(Icons.delete),
            color: Colors.white70));
  }
}
TheUltimateOptimist
  • 1,089
  • 4
  • 19

1 Answers1

0

You could use autoCloseDuration: Duration(seconds: 5), as a parameter and it will be closed after 5 seconds.

Full code:

CoolAlert.show(
  confirmBtnText: "Send Another",
  cancelBtnText: "To Home Page",
  showCancelBtn: true,
  context: context,
  autoCloseDuration: Duration(seconds: 5),
  animType :CoolAlertAnimType.slideInDown,
  type: CoolAlertType.success,
  // text: "Your Notification was sent successfully !",
  confirmBtnColor:Colors.amberAccent,
);
iqfareez
  • 555
  • 7
  • 21
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33986016) – Tushar Asodariya Mar 14 '23 at 08:10