feat(01-11): integrate router into main app with error handling
- Updated main.dart to use ProviderScope and MaterialApp.router - Integrated AppRouter with proper GoRouter configuration - Added comprehensive error handling with ErrorBoundary widget - Updated HomePage to use auth provider for logout functionality - Fixed SplashPage to use GoRouter navigation - Implemented router provider for Riverpod integration - Added proper resource disposal and restart functionality Files modified: - lib/main.dart (complete app structure) - lib/core/router/app_router.dart (router integration) - lib/features/authentication/presentation/pages/splash_page.dart (navigation fix) - lib/features/home/presentation/pages/home_page.dart (logout implementation)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
/// Splash page for initial loading and authentication state checking
|
||||
///
|
||||
@@ -33,18 +34,14 @@ class _SplashPageState extends ConsumerState<SplashPage> {
|
||||
|
||||
if (currentUser != null) {
|
||||
// User is authenticated, navigate to home
|
||||
// TODO: Use GoRouter when integrated
|
||||
// Navigator.of(context).pushReplacementNamed('/home');
|
||||
|
||||
// For now, we'll use a simple navigation
|
||||
Navigator.of(context).pushReplacementNamed('/home');
|
||||
if (mounted) {
|
||||
context.go('/home');
|
||||
}
|
||||
} else {
|
||||
// User is not authenticated, navigate to login
|
||||
// TODO: Use GoRouter when integrated
|
||||
// Navigator.of(context).pushReplacementNamed('/login');
|
||||
|
||||
// For now, we'll use a simple navigation
|
||||
Navigator.of(context).pushReplacementNamed('/login');
|
||||
if (mounted) {
|
||||
context.go('/login');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle authentication state check errors
|
||||
@@ -52,8 +49,10 @@ class _SplashPageState extends ConsumerState<SplashPage> {
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
// On error, navigate to login for safety
|
||||
Navigator.of(context).pushReplacementNamed('/login');
|
||||
// On error, navigate to login for safety
|
||||
if (mounted) {
|
||||
context.go('/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user