Milad-Akarie / auto_route_library

Flutter route generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to properly restore page by provided url

EvaNizhni opened this issue · comments

commented

Good day,

I have a case when one user can copy link from address, then send it to another user and this user should open exactly the same page by provided address.

Is it possible to provide this behaviour automatically, or I should parse address on start of the app and then restore page?

Thank you in advance!

@EvaNizhni that should be done automatically on web.

commented

I created small example, and I can't do this automatically. The full example you can find in archive
auto_router_example.zip

.

Left part is navigation part. Right is content. Each page has id in address. I select the second page, copy address, go to another tab, paste address and on content part i have got content for initial first page. The gif is bellow.

Screen.Recording.2022-07-04.at.11.52.28.mov

Could you please help me, how to save page content by concrete link?

@EvaNizhni both of your routes [first,second] have the same path ':id', the result you're getting makes complete sense because both paths match /second

I suppose your setup should look something like this

@MaterialAutoRouter(
  routes: <AutoRoute>[
    CustomRoute(
      page: TheMainPage,
      initial: true,
      children: [
        CustomRoute(
          path: 'first',
         initial: true,
          page: TheFirstPage,
          transitionsBuilder: TransitionsBuilders.slideBottom,
          durationInMilliseconds: 300,
        ),
        CustomRoute(
          path: 'second',
          page: TheSecondPage,
          transitionsBuilder: TransitionsBuilders.slideBottom,
          durationInMilliseconds: 300,
        ),
      ],
    ),
  ],
)
commented

@Milad-Akarie Thanks, It helps, but this close my way for configuring :id via @PathParam() from widget. Does it mean, that I can't use PathParam and open correct page on reload?

that should be done automatically on web.

@Milad-Akarie How about mobile? Any pointers on how to restore from a path? My use case is notifications that link to specific pages in the app.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions