我怎样才能弹出一个颤振冷静警报对话框



我有一个类,它返回一个删除帖子的按钮,并且我添加了用于弹出确认的coollarm包,但每次我点击"是"时;它弹出了我所有的主页,而不是弹出窗口,弹出对话框仍然保留在屏幕上。我的代码有问题吗?

这是按钮类代码:

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

您可以使用autoCloseDuration: Duration(seconds: 5),作为一个参数,它将在5秒钟后关闭。

完整代码:

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

相关内容

  • 没有找到相关文章

最新更新