routemaster icon indicating copy to clipboard operation
routemaster copied to clipboard

pop() flow between different stacks

Open zombie6888 opened this issue 2 years ago • 0 comments

Let' say i have routes:

/page1/:id

/page2

/page3

and i want to go from page1 to page2, then go to page3 and go back same way as i go forward (from page3 to page2, and then back to page1) Since i have 3 different stacks i can't use Routemaster.of(context).pop() because it will go to '/', which is tab page in my case.

I can use history.back(). From /page3 i go back to /page2 but then, when i call history.back() on /page2 it goes back to /page3 and my flow stucked and looped between thoose 2 pages.

Another way is reorder routes this way:

/page1/:id

/page1/:id/page2

/page1/:id/page2/page3

2 the problems with this approach:

if i want to add /page4 and also i want to go to page2 from page 4 i should repeat all route parts from page2 so it becomes:

/page1/:id

/page1/:id/page2

/page1/:id/page2/page3

/page4/page2/page3

/page4/page2

Instead of 4 routes i need to add 5. And it will be more, if from page2 i want to go somewhere else, for example it might be:

/page1/:id

/page1/:id/page2

/page1/:id/page2/page3
 
/page1/:id/page2/page5

/page4/page2

/page4/page2/page3

/page4/page2/page5

instead of :

/page1/:id

/page2

/page3

/page4

/page5

it's already 7 routes instead of 5 and route tree could be much more complicated.

Second problem is path parameters. page2 doesn't know about '/page1/:id' id parameter, but in order to go from /page1/:id/page2/ to /page1/:id/page2/page3 i should get it from current path.

zombie6888 avatar May 21 '22 17:05 zombie6888