I am trying to achieve a deep-link navigation structure as follows:
/ --> Home
/settings --> Settings Page
/settings/colortheme --> ColorThemePage
This is easy to achieve by annotating $Router like so, and let the build_runner do its thing:
@MaterialAutoRouter(
replaceInRouteName: 'Page,Route',
routes: <AutoRoute>[
AutoRoute(path: '/', page: HomePage, initial: true),
AutoRoute(path: '/settings', page: SettingsPage),
AutoRoute(path: '/settings/colortheme', page: ColorThemePage),
],
)
class $AppRouter{}
I want to achieve: if user navigates to '/settings/colortheme' by any means (in-app or via deep-link) I want the ColorThemePage to open, but then if the user navigates back, I want him to land on the settings page, and when he navigates back again, he comes to the home page. How is such a behavior with AutoRouter possible in Flutter?
It seems to me that I would have to push HomePage, SettingsPage, ColorThemePage in this order to achieve the desired behavior when navigating back. However this is convoluted and I am not sure how this can work in case of deep links that are handled by AutoRouter.
Has anyone had a similar problem?