logo和名称替换
This commit is contained in:
@@ -2,7 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:hgmj/tools_base/widget/common_alert.dart';
|
||||
import 'package:wydj/tools_base/widget/common_alert.dart';
|
||||
|
||||
import '../tools_base/toast.dart';
|
||||
|
||||
@@ -15,13 +15,17 @@ class PermissionUtil {
|
||||
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||
// 按 API 级别(sdkInt)判断:Android 13(API 33)起用照片权限,以下用存储权限。
|
||||
// 不能用 version.release(营销版本号字符串,ROM 可能写成 "12L" 等致解析跑偏)
|
||||
permission = androidInfo.version.sdkInt < 33 ? Permission.storage : Permission.photos;
|
||||
permission = androidInfo.version.sdkInt < 33
|
||||
? Permission.storage
|
||||
: Permission.photos;
|
||||
}
|
||||
return _ensure(permission, '需要相册权限才能继续');
|
||||
}
|
||||
|
||||
static Future<bool> checkPhotoAddOnlyPermission() async {
|
||||
final permission = (Platform.isIOS || Platform.isMacOS) ? Permission.photosAddOnly : Permission.storage;
|
||||
final permission = (Platform.isIOS || Platform.isMacOS)
|
||||
? Permission.photosAddOnly
|
||||
: Permission.storage;
|
||||
return _ensure(permission, '需要相册权限才能继续');
|
||||
}
|
||||
|
||||
@@ -39,7 +43,8 @@ class PermissionUtil {
|
||||
// 会误判成永久拒绝、不弹框直接去设置。所以 Android 一律先 request(),
|
||||
// 由系统决定弹框还是立即返回结果;iOS/macOS 的 status 可靠,永久拒绝/受限直接去设置。
|
||||
// 前提:申请的权限必须已在 AndroidManifest 声明,否则 request() 会立即返回 denied 不弹框。
|
||||
if ((Platform.isIOS || Platform.isMacOS) && (status.isPermanentlyDenied || status.isRestricted)) {
|
||||
if ((Platform.isIOS || Platform.isMacOS) &&
|
||||
(status.isPermanentlyDenied || status.isRestricted)) {
|
||||
_toSettings();
|
||||
return false;
|
||||
}
|
||||
@@ -49,7 +54,8 @@ class PermissionUtil {
|
||||
|
||||
/// 处理 request() 后的结果:授权放行;永久拒绝引导去设置;普通拒绝弹 toast,
|
||||
/// 下次仍会弹系统授权框,避免误报"已禁止权限"
|
||||
static bool _handleStatus(PermissionStatus status, {String denyTip = '未授权,无法继续'}) {
|
||||
static bool _handleStatus(PermissionStatus status,
|
||||
{String denyTip = '未授权,无法继续'}) {
|
||||
if (status.isGranted || status.isLimited) return true;
|
||||
if (status.isPermanentlyDenied || status.isRestricted) {
|
||||
_toSettings();
|
||||
|
||||
Reference in New Issue
Block a user