# PlatformException：PERMISSION_DENIED，由于权限范围不足，操作被拒绝

- **ID:** `flutter/insufficient-permission-scope`
- **领域:** flutter
- **类别:** auth_error
- **错误码:** `PERMISSION_DENIED`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

请求了平台特定权限（如摄像头、位置、存储），但用户仅授予了有限范围，或者未在应用清单中声明该权限。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.19 | active | — | — |
| Dart 3.3 | active | — | — |
| Android 14 | active | — | — |
| iOS 17.2 | active | — | — |

## 解决方案

1. ```
   Use the permission_handler package to explicitly request the permission and check the status before performing the operation. Example: `final status = await Permission.camera.request(); if (status.isGranted) { // proceed } else { // show rationale }`
   ```
2. ```
   Declare the exact permission in AndroidManifest.xml (e.g., <uses-permission android:name="android.permission.CAMERA" />) and in Info.plist (e.g., NSCameraUsageDescription).
   ```
3. ```
   For Android 14+ granular media permissions, request each sub-permission (e.g., ACCESS_MEDIA_LOCATION) separately using the `photo_manager` or similar package that handles scoped storage.
   ```

## 无效尝试

- **** — Over-declaring permissions may cause app store rejection or user distrust; also, runtime permission requests still require user consent and proper handling. (50% 失败率)
- **** — Ignoring the result means the app proceeds without the required permission, leading to the same exception when the operation is attempted. (75% 失败率)
- **** — Lowering compileSdkVersion may introduce security vulnerabilities and prevent use of newer APIs; it also does not resolve runtime permission denials on newer devices. (85% 失败率)
