auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

How to clear sub-stack when changing between tabs?

Open RTsosssoldi opened this issue 2 years ago • 3 comments

I'vs got 4 tabs with the relative nested page. What i'm trying to accomplish is:

  1. navigatin to a subpage of Tab1
  2. switching to Tab2 through the bottomBar
  3. navigating again on Tab1 -> HERE i would like to see the root page of tab1 instead the one of the step1

is it possible?

RTsosssoldi avatar Mar 11 '22 10:03 RTsosssoldi

Ok, i manage to handle it with: onTap: (index) { tabsRouter.stackRouterOfIndex(index)?.popUntilRoot(); tabsRouter.setActiveIndex(index); },

but app show for a microsecond the page popped, is the rea method to avoid it?

RTsosssoldi avatar Mar 11 '22 14:03 RTsosssoldi

Probably a bit late, but you can change to pop on exit instead of entry

onTap: (index) { tabsRouter.stackRouterOfIndex(tabsRouter.activeIndex)?.popUntilRoot(); tabsRouter.setActiveIndex(index); },

AlexDochioiu avatar Jul 21 '22 15:07 AlexDochioiu

Also, you might want to change order and to tabsRouter.setActiveIndex(index); first to make sure you don't see the hidden route popping

onTap: (index) { oldIndex = tabsRouter.activeIndex; tabsRouter.setActiveIndex(index); tabsRouter.stackRouterOfIndex(oldIndex)?.popUntilRoot(); },

AlexDochioiu avatar Jul 21 '22 15:07 AlexDochioiu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Oct 11 '22 08:10 github-actions[bot]