Search code examples
flutterdartstacknavigator

How do I delete all of the pages stacked through push in bottom navigation?


I use the bottom navigation bar. Various pages remain stacks through push on A_Page, one of the bottom navigation items.

If you press the button on the top page, I want to clear all stacked pages, leaving only A_Page, the first page of the bottom navigation item. I think using Navigator.pop several times is a bad code.

How do I clear a pushed page except the first bottom navigation item page?


Solution

  • Navigator.popUntil(context, (route) => route.isFirst);