go_router_riverpod icon indicating copy to clipboard operation
go_router_riverpod copied to clipboard

Use GoRouter.refreshListenable

Open torbenkeller opened this issue 1 year ago • 1 comments

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.

torbenkeller avatar Nov 25 '23 18:11 torbenkeller

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.

lucavenir avatar Nov 26 '23 13:11 lucavenir