router.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 '../features/auth/presentation/login_page.dart';
  5. import '../features/MediaTestPage/presentation/media_test_page.dart';
  6. class AppRouter {
  7. static final router = GoRouter(
  8. routes: [
  9. GoRoute(
  10. path: '/',
  11. builder: (context, state) => const LoginPage(),
  12. ),
  13. GoRoute(
  14. path: '/mainTab',
  15. builder: (context, state) => const MainTabPage(),
  16. ),
  17. GoRoute(
  18. path: '/mediaTest',
  19. builder: (context, state) => const MediaTestPage(),
  20. ),
  21. ],
  22. errorBuilder: (context, state) => Scaffold(
  23. appBar: AppBar(
  24. title: const Text('页面未找到'),
  25. ),
  26. body: Center(
  27. child: Column(
  28. mainAxisAlignment: MainAxisAlignment.center,
  29. children: [
  30. const Icon(
  31. Icons.error_outline,
  32. size: 64,
  33. color: Colors.grey,
  34. ),
  35. const SizedBox(height: 16),
  36. Text(
  37. '页面未找到: ${state.uri}',
  38. style: const TextStyle(fontSize: 16),
  39. ),
  40. const SizedBox(height: 16),
  41. ElevatedButton(
  42. onPressed: () => context.go('/'),
  43. child: const Text('返回首页'),
  44. ),
  45. ],
  46. ),
  47. ),
  48. ),
  49. );
  50. }