123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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<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'];
- }
- }
|