5

I am trying to make an app with Flutter which use Bottom Navigation Bars. I want to keep my previous visited screens in navigation stack as in Youtube and Instagram apps. For example , assume that I have 3 different bottom navigation bars (A,B and C). After clicking on the tabs A, B and C respectively, I want to return to C, B and A respectively.

This is my main goal, but I have a secondary goal If it is possible to implement.

In Instagram and Youtube, If you click tabs in order A -> B -> C -> B -> C (Now you are on tab C) and after that when you started to click back button it returns you to C -> B -> A tabs. Basically, each tab can be placed once in navigation stack. If you visite same tab more than once, previous screen of same tab is deleted from navigation stack.

I am searching the solution for this problem for two days but I couldn't find. I've even tested the flutter-go app which is made by alibaba developers, when I click to back button app is just closing.

I would appreciate any help for this problem.

safaer
  • 191
  • 1
  • 2
  • 11

1 Answers1

0

Navigator.of(context).pushNamedAndRemoveUntil('/screenB', ModalRoute.withName('/screenA'));

try this one on last FragmentC

Richa Shah
  • 930
  • 3
  • 12
  • 27