fish 7 months ago
parent
commit
ded0a601e2
1 changed files with 32 additions and 0 deletions
  1. 32 0
      lib/routes.dart

+ 32 - 0
lib/routes.dart

@@ -16,4 +16,36 @@ class Routes {
     GetPage(
         name: second, page: () => const SecondView(), binding: SecondBinding())
   ];
+
+  static Future<T> push<T>(String routeName, {params}) async {
+    Map<String, dynamic> map = {};
+    map.putIfAbsent("obj", () => params);
+    return await Get.toNamed(routeName, arguments: map);
+  }
+
+  static Future<T> replacePush<T>(String routeName, {params}) async {
+    Map<String, dynamic> map = {};
+    map.putIfAbsent("obj", () => params);
+    return await Get.offNamed(routeName, arguments: map);
+  }
+
+  static Future<T> off<T>(String routeName, {params}) async {
+    Map<String, dynamic> map = {};
+    map.putIfAbsent("obj", () => params);
+    return await Get.off(routeName, arguments: map);
+  }
+
+  static Future<T> replaceAllPush<T>(String routeName, {params}) async {
+    Map<String, dynamic> map = {};
+    map.putIfAbsent("obj", () => params);
+    return await Get.offAllNamed(routeName, arguments: map);
+  }
+
+  static pop<T>({result}) {
+    return Get.back(result: result);
+  }
+
+  static getParams<T>() {
+    return Get.arguments == null ? null : Get.arguments['obj'];
+  }
 }