Reputation: 176
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?
Upvotes: 0
Views: 560
Reputation: 76
You can use named routes
Navigator.of(context).pushNamedAndRemoveUntil(
'/first_screen',
(Route<dynamic> route) => false,
);
Upvotes: 0