feat(delete):删除里面文件夹
This commit is contained in:
53
lib/utils/PermissionUtil.dart
Normal file
53
lib/utils/PermissionUtil.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'dart:io';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class PermissionUtil{
|
||||
/// 安卓权限
|
||||
static List<Permission> androidPermissions = <Permission>[
|
||||
// 在这里添加需要的权限
|
||||
Permission.storage
|
||||
];
|
||||
|
||||
/// ios权限
|
||||
static List<Permission> iosPermissions = <Permission>[
|
||||
// 在这里添加需要的权限
|
||||
Permission.storage
|
||||
];
|
||||
|
||||
static Future<Map<Permission, PermissionStatus>> requestAll() async {
|
||||
if (Platform.isIOS) {
|
||||
return await iosPermissions.request();
|
||||
}
|
||||
return await androidPermissions.request();
|
||||
}
|
||||
|
||||
static Future<Map<Permission, PermissionStatus>> request(
|
||||
Permission permission) async {
|
||||
final List<Permission> permissions = <Permission>[permission];
|
||||
return await permissions.request();
|
||||
}
|
||||
|
||||
static bool isDenied(Map<Permission, PermissionStatus> result) {
|
||||
var isDenied = false;
|
||||
result.forEach((key, value) {
|
||||
if (value == PermissionStatus.denied) {
|
||||
isDenied = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return isDenied;
|
||||
}
|
||||
|
||||
|
||||
/// 检查权限
|
||||
static Future<bool> checkGranted(Permission permission) async {
|
||||
PermissionStatus storageStatus = await permission.status;
|
||||
if (storageStatus == PermissionStatus.granted) {
|
||||
//已授权
|
||||
return true;
|
||||
} else {
|
||||
//拒绝授权
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user