lucavenir / go_router_riverpod

An example on how to use Riverpod + GoRouter
460 stars 68 forks source link

Questions about the build #24

Closed TheHypnoo closed 1 year ago

TheHypnoo commented 1 year ago

Hi, sorry to bother you with my questions, but I've been trying for several weeks to finish implementing GoRouter + Riverpod + Firebase and with the code in the repository, it's not quite possible.

I comment my problem below: In this case, it goes over the logic of the AutoDisposeAsyncNotifier build. One of the main doubts is that I want to read two Streams, one that is if the user is authenticated or not, and another one is a global Stream of the complete User, where I look if it has a field in true or false, to redirect it to a place or another. The problem, is that although the build is done, it is always false at first and then always redirects me to the login and then makes the animation to the home. Wouldn't there be a way to avoid that?

Yes, no, it would be mandatory to add a Splash? My intention was depending on the values, to have one InitialLocation or another.

lucavenir commented 1 year ago

Wouldn't there be a way to avoid that

I'm not sure I've understood, but yes, there's always a way (: Although some code should be shared to have a clearer idea, I'd say your best shot is to implement two different redirects in two different parts of the application. One should be a global redirect, the other should be referring to some subtree.

would it be mandatory to add a Splash?

No, I'm just playing around to introduce a complete example for the community, so your inputs are highly appreciated. You can show a splash / loading screen conditionally, based on some state, that's for sure. Your SplashPage could be just listening to some state condition and decide what Widget(s) to render.