How to kill a navigation stack POP all previous screens in Flutter?

Posted by Jessica Taylor | Updated on

If you want to kill a navigation stack POP all previous screens in Flutter? To pop multiple screens from the navigation stack, like in your given scenario we can use Navigator.popUntil. It takes a BuildContextand a RoutePredicate as parameters. The Navigator calls pop until the returned value by the given RoutePredicate is true.

Here is very basic example. It uses ModalRoute.withName to create the RoutePredicate:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers