MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

Flutter : How to dismiss an AlertDialog on Button?

Flutter

Problem

I’m showing an AlertDialog on my App, but when I click on no/cancel then AlertDialog doesn’t dismiss, it keep popping the route where I came from. I’ve used Navigator.of(context).pop(); and Navigator.pop(context, false); but both are not working.

Solution

To Dismiss an AlertDialog Navigator.of(context).pop(); works but in my case below code worked.

Navigator.of(context, rootNavigator: true).pop('dialog');

That’s All.

Thanks for reading.

Keep Coding.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x