Mobile Application Architecture
Implementing Role-Based Navigation in Flutter
By Pawan Kumawat • Published Jan 05, 2026 • 9 min read
1. Multi-Role Navigation Architecture
Applications that serve different user types (such as Landlord vs Tenant, or Admin vs Customer) require decoupled route graphs. Instead of littering `if (user.role == 'landlord')` conditional statements inside every widget screen, route selection should be handled declaratively at the top router level.
2. Declarative Redirects with GoRouter
GoRouter provides a `redirect` callback that evaluates user authentication state and user role enumerations before presenting screens:
app_router.dart
enum UserRole { landlord, tenant, unauthenticated }
final routerProvider = Provider<GoRouter>((ref) {
final authState = ref.watch(authStateProvider);
return GoRouter(
initialLocation: '/login',
redirect: (BuildContext context, GoRouterState state) {
final isLoggedIn = authState.role != UserRole.unauthenticated;
final isLoggingIn = state.matchedLocation == '/login';
if (!isLoggedIn) return isLoggingIn ? null : '/login';
if (isLoggingIn) {
if (authState.role == UserRole.landlord) return '/landlord-dashboard';
if (authState.role == UserRole.tenant) return '/tenant-dashboard';
}
return null; // Retain target location
},
routes: [
GoRoute(path: '/login', builder: (c, s) => const LoginScreen()),
GoRoute(path: '/landlord-dashboard', builder: (c, s) => const LandlordDashboard()),
GoRoute(path: '/tenant-dashboard', builder: (c, s) => const TenantDashboard()),
],
);
});
3. Handling Role Transitions & Logout
Upon logout, clearing the auth state notifies the router listener, automatically resetting navigation stacks back to `/login` without leaving lingering memory references or back-button state leaks.