lucavenir / go_router_riverpod

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

Use GoRouter.refreshListenable #35

Open torbenkeller opened 9 months ago

torbenkeller commented 9 months ago

GoRouter can get a listenable and refreshes if the listenable notifies the router. In your code you are not using it, but I think it would be the better way to do it. You are listening to the current auth state and rebuild the whole router on a change. The state remains intact because of the global key, but this is probably more expensive than creating a listenable and let GoRouter refresh itself.

lucavenir commented 9 months ago

Thank you for raising this issue. It was not intended to rebuild the whole router provider, so I'm guessing I wrote a ref.watch instead of a ref.listen.