How to apply a common redirect to a specific group of routes?
I am using the go_router package in Flutter and need to apply a shared redirect logic (e.g., an admin check) to a specific subset of routes. I'm considering several approaches: I can use the global redirect on the GoRouter instance: final GoRouter _router = GoRouter( redirect: (context, state) { //Actual routing... return null; }, // ... ); However, I don't like this approach, because the global redirect shouldn't care about this redirect. I could create a commonRedirect function and pass it manually to the redirect parameter of every single GoRoute that needs it: String? adminRedirect(BuildCo
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.