Is it possible to keep X number of a route in back...
# compose
y
Is it possible to keep X number of a route in back stack and pop the oldest one once it reaches the limit?
i
The back stack is a stack - you can only affect the topmost elements
y
It will be the top route but multiples of one
I have a route that can navigate to itself
So the user can just navigate for a while and have a really hard time tapping back 100 times to get back to the previous route
But right - you say I cannot remove the oldest one 🤔 and removing the newest one wouldn't be useful
o
@YASAN have you considered something like the following: Screen A -> Screen B -> .... Screen X -> Screen A When user hits back on Screen X, just pop all elements on the back stack up until Screen A again.
You can probably play around with using different tags in case there are multiple instances of Screen A on the stack and you want to pop back to a specific one
And you can also check if an instance of Screen A or one with a specific tag exists in the backstack if you wanted to perform different logic when user hits back in Screen X
i
Yep, the only built in functionality like this would be the
launchSingleTop
flag, which would prevent multiple instances from being on the top of the stack - i.e., automatically popping the previous entry as you navigate to its replacement
👍 1
1