routes.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_provider_demo/index_page.dart';
  3. import 'package:flutter_provider_demo/pages/addpage_page.dart';
  4. /// Description: routes
  5. /// Time : 09/03/2023 Sunday
  6. /// Author : liuyuqi.gov@msn.cn
  7. class Routes {
  8. static const String home = '/';
  9. static const String index = '/index';
  10. static const String login = '/login';
  11. static const String carAdd = "/carAdd";
  12. static MaterialPageRoute<dynamic> generateRoute(RouteSettings settings) {
  13. switch (settings.name) {
  14. case home:
  15. return MaterialPageRoute<dynamic>(
  16. builder: (_) => const Scaffold(),
  17. settings: settings,
  18. );
  19. case index:
  20. return MaterialPageRoute<dynamic>(
  21. builder: (_) => const IndexPage(),
  22. settings: settings,
  23. );
  24. case login:
  25. return MaterialPageRoute<dynamic>(
  26. builder: (_) => const IndexPage(),
  27. settings: settings,
  28. );
  29. case carAdd:
  30. return MaterialPageRoute<dynamic>(
  31. builder: (_) => const AddcardPage(),
  32. settings: settings,
  33. );
  34. default:
  35. return MaterialPageRoute<dynamic>(
  36. builder: (_) => const Scaffold(),
  37. settings: settings,
  38. );
  39. }
  40. }
  41. void go(BuildContext context, String routeName) {
  42. Navigator.pushNamed(context, routeName);
  43. }
  44. }