csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
441 stars 96 forks source link

Reusing screens #353

Closed Lootwig closed 2 years ago

Lootwig commented 2 years ago

Is there a more elegant way to have the same screen reachable from different locations than defining the same GoRoute & builder multiple times with different paths?

Hesamedin commented 2 years ago

I didn't get what do you mean @Lootwig. Please give an example. I reach the same screen from different locations using: context.pushNamed('screen_a') or context.pushNamed('screen_b', params: {'id': 'product_id'})

Lootwig commented 2 years ago

Is the location parameter of the GoRoute ignored in that case? If so, why is it a mandatory parameter in the first place?

leoshusar commented 2 years ago

Did you mean path parameter? It's is still used under the hood (and in the browser bar). Named location just searches for it. When you are on /home/page, you can do context.push('/my/totally/random/location') (or pushNamed('somewhere')) and it will work just fine.