24 lines
769 B
Dart
24 lines
769 B
Dart
|
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);
|
||
|
}
|
||
|
}
|