routes.dart 976 B

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