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

Exemple with FR and my problem #303

Closed iAmTosuj closed 2 years ago

iAmTosuj commented 2 years ago

Hello, I made an example, for these issue https://github.com/csells/go_router/issues/279 and https://github.com/csells/go_router/issues/282.

my example https://github.com/iAmTosuj/go_router_exemple, I left comments in the code.

I described everything in the readme and will duplicate it here.

Feature request.

The application has authentication by code and deep link. I open the application using the link and I need to get to it after I enter the authentication code. To do this, I need to remember the link before authentication. It would be convenient if I received not only a string, but also the name of this link, so it would be easier to check it. You can see an example in the router_redirect file.

in the state Router, it would be possible to transmit the entire route history in a flat list. In my case, I would take the last matched route and check its name and the name of my deeplinks. Then you don't need to write regular expressions for location params

Strange behavior.

The page is recreated every time you return to it or use hot restart. But the strangest thing is that all final fields are created anew, and the old fields remain in widget. You can see an example with bloc in the main_page file.

Before that, I used the auto_router library and there was no such problem, the constructor was never called when going back through history or when use hot restart.

i can do this, but how can I change the parameters of this page if they are passed to the constructor?

final mainPage = MainPage();

GoRoute(path: '/main', builder: (context, state) => mainPage,)

You can make it so that if the page has already been created, it will be cached and when you return to it, a new instance will not be created, it will be taken from the cache?

Maybe I'm doing something wrong and I'm having these problems. Please help if possible.

csells commented 2 years ago

You can ask Flutter to cache the state of any widget you like -- that's what a StatefulWidget is. Put the state that you want kept between invocations into your State object and override didUpdateWidget for new data in the associated widget. You can read more here: https://flutterbyexample.com/lesson/stateful-widget-lifecycle