final router = GoRouter(
redirect: (context, state) {
final auth = AuthService.instance;
final isLogin = state.matchedLocation == '/login';
if (!auth.isLoggedIn && !isLogin) return '/login';
if (auth.isLoggedIn && isLogin) return '/';
return null;
},
routes: [
GoRoute(path: '/login', builder: (_, __) => const LoginScreen()),
ShellRoute(
builder: (_, __, child) => MainScaffold(child: child),
routes: [
GoRoute(path: '/', builder: (_, __) => const HomeTab()),
GoRoute(path: '/explore', builder: (_, __) => const ExploreTab()),
GoRoute(path: '/profile', builder: (_, __) => const ProfileTab()),
],
),
GoRoute(
path: '/details/:id',
builder: (_, state) {
final id = state.pathParameters['id']!;
return DetailScreen(id: id);
},
),
],
);