fix: update initial route to '/login' and use context.go for navigation in LoginScreen

This commit is contained in:
Nils-Johan Gynther
2026-04-21 22:13:59 +02:00
parent 78bcf9bc98
commit b87c877b38
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import '../../features/auth/presentation/login_screen.dart';
final appRouterProvider = Provider<GoRouter>((ref) {
return GoRouter(
initialLocation: '/recipes',
initialLocation: '/login',
routes: [
GoRoute(
path: '/login',
@@ -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<LoginScreen> {
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');
}
}
}