router.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'package:flutter/material.dart';
  2. import 'package:go_router/go_router.dart';
  3. import 'package:sino_med_cloud/features/main_tab_page.dart';
  4. import 'package:sino_med_cloud/l10n/app_localizations.dart';
  5. import '../features/auth/presentation/login_page.dart';
  6. import '../features/MediaTestPage/presentation/media_test_page.dart';
  7. import '../core/network/pages/no_network_page.dart';
  8. class AppRouter {
  9. static final router = GoRouter(
  10. routes: [
  11. GoRoute(
  12. path: '/',
  13. builder: (context, state) => const LoginPage(),
  14. ),
  15. GoRoute(
  16. path: '/mainTab',
  17. builder: (context, state) => const MainTabPage(),
  18. ),
  19. GoRoute(
  20. path: '/mediaTest',
  21. builder: (context, state) => const MediaTestPage(),
  22. ),
  23. GoRoute(
  24. path: '/noNetwork',
  25. builder: (context, state) => const NoNetworkPage(),
  26. ),
  27. ],
  28. errorBuilder: (context, state) {
  29. final l10n = AppLocalizations.of(context)!;
  30. return Scaffold(
  31. appBar: AppBar(
  32. title: Text(l10n.pageNotFound),
  33. ),
  34. body: Center(
  35. child: Column(
  36. mainAxisAlignment: MainAxisAlignment.center,
  37. children: [
  38. const Icon(
  39. Icons.error_outline,
  40. size: 64,
  41. color: Colors.grey,
  42. ),
  43. const SizedBox(height: 16),
  44. Text(
  45. l10n.pageNotFoundWithUri(state.uri.toString()),
  46. style: const TextStyle(fontSize: 16),
  47. ),
  48. const SizedBox(height: 16),
  49. ElevatedButton(
  50. onPressed: () => context.go('/'),
  51. child: Text(l10n.returnHome),
  52. ),
  53. ],
  54. ),
  55. ),
  56. );
  57. },
  58. );
  59. }