admin管理员组

文章数量:1241086

I'm looking for a solution which contains exactly what you see described in this article, but with the additional feature of displaying a bottom navigation bar that is specific to the current app state (e.g. display distinct bottom navigation icons pointing to according target screens if the app user is signed in or not, like it is suggested here). As suggested in that link, you would most likely generate the bottom navigation bar icons used by the app dynamically; that's clear and understandable. But my question here is; how you would provide the app-state specific StatefullShellBranches for your StatefullShellRoute ?

I first thought about using a single GoRouter config with a single StatefulShellRoute, with all of your app's base navigation screens added as the according StatefulShellBranches (both the branches shown in the app when the user is signed in and the branches shown when the user is signed out).

Pros:

  • Makes it easy to redirect in between private and public app screens based on auth state; which is essential regarding peepz arriving on a specific screen through deep link.

Cons:

  • Private app screens requiring authentication are present in the same route configuration as when the app user is signed out. Which feels odd, as network requests related to the private screens should not be executed while the app user is not authenticated, and vice-versa.

I then thought about another possible way: Provide two distinct dynamic go router configurations, and toggle the active configuration when the authentication state changes. But this basically swaps the above-mentioned Pro & Con, hence the solution still does not seem feasible.

I couldn't find anything else online after a significant amount of time; how could you implement this?

本文标签: