From b87c877b38863c85c0a8804046536b5b2d9f51e1 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Tue, 21 Apr 2026 22:13:59 +0200 Subject: [PATCH] fix: update initial route to '/login' and use context.go for navigation in LoginScreen --- flutter/lib/core/router/app_router.dart | 2 +- flutter/lib/features/auth/presentation/login_screen.dart | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flutter/lib/core/router/app_router.dart b/flutter/lib/core/router/app_router.dart index 66eb2561..f9869a2b 100644 --- a/flutter/lib/core/router/app_router.dart +++ b/flutter/lib/core/router/app_router.dart @@ -5,7 +5,7 @@ import '../../features/auth/presentation/login_screen.dart'; final appRouterProvider = Provider((ref) { return GoRouter( - initialLocation: '/recipes', + initialLocation: '/login', routes: [ GoRoute( path: '/login', diff --git a/flutter/lib/features/auth/presentation/login_screen.dart b/flutter/lib/features/auth/presentation/login_screen.dart index 8550baf9..e0278f9e 100644 --- a/flutter/lib/features/auth/presentation/login_screen.dart +++ b/flutter/lib/features/auth/presentation/login_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; import '../data/auth_providers.dart'; class LoginScreen extends ConsumerStatefulWidget { @@ -28,7 +29,7 @@ class _LoginScreenState extends ConsumerState { if (mounted) { final state = ref.read(authStateProvider); if (state is AsyncData && state.value != null) { - if (context.mounted) Navigator.of(context).pushReplacementNamed('/recipes'); + if (context.mounted) context.go('/recipes'); } } }