flutter_cool_alert
flutter_cool_alert copied to clipboard
Navigator.pushReplacement() not working on confirm button tap
ListTile(
iconColor: Colors.white,
textColor: Colors.white,
leading: Icon(Icons.logout_outlined),
title: Text("Logout"),
onTap: () {
CoolAlert.show(
context: context,
type: CoolAlertType.confirm,
title: 'Logout',
text: 'Are you sure you want to logout?',
confirmBtnText: 'Yes',
confirmBtnColor: Colors.red,
cancelBtnText: 'No',
closeOnConfirmBtnTap: true,
onConfirmBtnTap: () async {
_prefs.setString(Prefs.adminUser, '');
_prefs.setBool(Prefs.isLoggedIn, false);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => Login()));
});
},
)
Above is the code snippet from my app. When the 'Yes' button is clicked, it erases the SharedPreference data, but not navigates to the Login Screen. Why?
I have same issue. Did you find solution for it?
I have same issue. Did you find solution for it?
No. I have used another library for the same.
I also have the same issue... It seems it's a bug of some sort
This issue occurs because the dialog is still on the screen when you try to navigate. Adding a delay of a few milliseconds before navigating provides a workaround.