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));
}
}