mobile_skt/lib/router/router.util.dart

24 lines
769 B
Dart
Raw Normal View History

2024-04-10 17:38:23 +08:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/store/resource.store.dart';
import 'package:sk_base_mobile/util/snack_bar.util.dart';
class RouterUtil {
static Future<T?> toNamed<T>(String routeName, {arguments}) async {
//关闭键盘
if (Get.context != null) {
FocusScope.of(Get.context!).requestFocus(FocusNode());
}
bool isExsited = ResourceService.to.resources
.firstWhereOrNull((element) => element.path == routeName) !=
null;
if (!isExsited) {
SnackBarUtil().info('您没有权限,请联系管理员分配权限,后期将隐藏无权限的菜单');
return null;
}
return await Get.toNamed<T?>(routeName, arguments: arguments);
}
}