Is there a way to have several paths pointing to the same page?
To give some context: I have a flutter app that handles screens via Bloc events. The Home HomeScreen can have multiple events, each showing a specific page. Hence the need to have multiple paths pointing to the same screen.
The following is an example of how I have tried to set up routes. Build it doesn’t work.
@MaterialAutoRouter(
routes: <AutoRoute>[
AutoRoute(path: '/routeA', page: HomeScreen),
AutoRoute(path: '/routeB', page: HomeScreen),
AutoRoute(path: '/routeC', page: HomeScreen),
AutoRoute(path: '/routeD', page: HomeScreen),
]
)
2
Answers
If homepage has multiple events, handle what the users sees in the home page
eg
My solution to this is creating different classes that point to the same widget.
So in your case, if you have the class
'HomeScreen'
you, want to create classes that point to it.And in your router
This will do the same effect with different paths that point to the same widget you’ve built, but makes you able to send in different information based on the path you send the user to.