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,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
|
||||
/// Home page for authenticated users
|
||||
///
|
||||
@@ -21,8 +21,18 @@ class HomePage extends ConsumerWidget {
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
onPressed: () async {
|
||||
// TODO: Implement logout functionality
|
||||
// await ref.read(authStateProvider.notifier).signOut();
|
||||
try {
|
||||
await ref.read(authProvider.notifier).signOut();
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Logout failed: ${e.toString()}'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: 'Logout',
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user