import 'package:get/get.dart'; import 'package:get_demo/pages/home/home_binding.dart'; import 'package:get_demo/pages/home/home_view.dart'; import 'package:get_demo/pages/second/second_binding.dart'; import 'package:get_demo/pages/second/second_view.dart'; /// Description: routes /// Time : 05/06/2023 Saturday /// Author : liuyuqi.gov@msn.cn class Routes { static const String home = "/home"; static const String second = "/second"; static final routes = [ GetPage(name: home, page: () => const HomeView(), binding: HomeBinding()), GetPage( name: second, page: () => const SecondView(), binding: SecondBinding()) ]; static Future push(String routeName, {params}) async { Map map = {}; map.putIfAbsent("obj", () => params); return await Get.toNamed(routeName, arguments: map); } static Future replacePush(String routeName, {params}) async { Map map = {}; map.putIfAbsent("obj", () => params); return await Get.offNamed(routeName, arguments: map); } static Future off(String routeName, {params}) async { Map map = {}; map.putIfAbsent("obj", () => params); return await Get.off(routeName, arguments: map); } static Future replaceAllPush(String routeName, {params}) async { Map map = {}; map.putIfAbsent("obj", () => params); return await Get.offAllNamed(routeName, arguments: map); } static pop({result}) { return Get.back(result: result); } static getParams() { return Get.arguments == null ? null : Get.arguments['obj']; } }