routes.dart 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'package:flutter/material.dart';
  2. import 'package:gobang/pages/home_page.dart';
  3. import 'package:gobang/pages/index_page.dart';
  4. import 'package:gobang/pages/login_page.dart';
  5. import 'package:gobang/pages/mine_page.dart';
  6. import 'package:gobang/pages/splash/splash_page.dart';
  7. /// Description: routes
  8. /// Time : 02/21/2024 Wednesday
  9. /// Author : liuyuqi.gov@msn.cn
  10. class Routes {
  11. static const String index = "/index";
  12. static const String home = "/home";
  13. static const String login = "/login";
  14. static const String mine = "/mine";
  15. static const String setting = "/mine/setting";
  16. static const String pay = "/pay";
  17. static const String splash = "/splash";
  18. static MaterialPageRoute<dynamic> onGenerateRoute(RouteSettings settings) {
  19. switch (settings.name) {
  20. case home:
  21. return MaterialPageRoute<dynamic>(
  22. builder: (_) => HomePage(),
  23. );
  24. case index:
  25. return MaterialPageRoute<dynamic>(
  26. builder: (_) => IndexPage(),
  27. );
  28. case splash:
  29. return MaterialPageRoute<dynamic>(
  30. builder: (_) => const SpalshPage(),
  31. );
  32. case mine:
  33. return MaterialPageRoute<dynamic>(
  34. builder: (_) => const MinePage(),
  35. );
  36. case login:
  37. return MaterialPageRoute<dynamic>(
  38. builder: (_) => const LoginPage(),
  39. );
  40. default:
  41. return MaterialPageRoute<dynamic>(
  42. builder: (_) => const Scaffold(
  43. body: Center(
  44. child: Text("404"),
  45. ),
  46. ),
  47. );
  48. }
  49. }
  50. static void popAndPushNamed(BuildContext context, String routePath) {
  51. Navigator.popAndPushNamed(context, routePath);
  52. }
  53. static void pushReplacementNamed(BuildContext context, String routePath) {
  54. Navigator.pushReplacementNamed(context, routePath);
  55. }
  56. }