route.dart 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:flutter/foundation.dart';
  2. import 'package:get/get.dart';
  3. class RouteName {
  4. static const start = '/start';
  5. static const init = '/init';
  6. static const test = '/test';
  7. static const home = '/home';
  8. static const signIn = '/signIn';
  9. static const gameLoading = '/gameLoading';
  10. static const providerDetail = '/providerDetail';
  11. static const needUpdate = '/needUpdate';
  12. static const settlement = '/settlement';
  13. static const homeSaveUserInfo = '/homeSaveUserInfo';
  14. static const mapsList = '/mapsList'; // 地图列表
  15. static const mapTO = '/mapTO'; // 地图场控
  16. static const userAdmin = '/userAdmin'; // 用户管理
  17. static const userRank = '/userRank'; // 个人排名
  18. static const groupRank = '/groupRank'; // 分组排名
  19. static const sportData = '/sportData'; // 数据详情
  20. static const setting = '/setting'; // 设置
  21. }
  22. class Route {
  23. static Future<bool> toLogin({
  24. bool canBack = true,
  25. bool thenBack = false,
  26. VoidCallback? thenToPageCall,
  27. }) async {
  28. dynamic arguments = thenToPageCall;
  29. if (thenBack) {
  30. arguments = () {
  31. Get.back(closeOverlays: true);
  32. };
  33. }
  34. Future<dynamic>? r;
  35. if (canBack) {
  36. r = Get.toNamed(RouteName.signIn, arguments: arguments);
  37. } else {
  38. r = Get.offAllNamed(RouteName.signIn, arguments: arguments);
  39. }
  40. if (r != null) {
  41. final r2 = await r;
  42. if (r2 is bool) {
  43. return r2;
  44. }
  45. }
  46. return false;
  47. }
  48. }