搜尋套件、儲存庫與 APP 分類

套件詳情v5.0.1

easy_permission_validator

PermissonHandler 是一個用於管理 Android 和 iOS 權限的套件,透過此套件,您可以輕鬆使用 PermissonHandler 庫。

AndroidiOSWindows
近 30 天下載
129
喜歡數
36
Pub 分數
150

安裝套件

flutter pub add easy_permission_validator

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Easy Permission Validator 是一個 Flutter 套件,可簡化 Android 與 iOS 的權限管理,提供直觀的介面來處理執行時權限。它封裝了 PermissionHandler 庫,讓開發者能以最少的程式碼請求、檢查與管理應用權限。該套件支援常見權限如相機、位置與儲存空間,確保跨平台行為一致。同時也提供明確的權限狀態回饋,並處理拒絕或限制存取等邊際情況。非常適合需要使用者同意才能使用敏感功能的應用。

適用情境

  • 在照片應用中請求相機訪問權限
  • 在使用地圖之前檢查位置權限
  • 管理檔案上傳的儲存存取
  • 處理跨平台應用中的執行時權限
  • 確保符合隱私法規

主要特色

  • 用於權限檢查的簡單 API
  • 支援 Android 和 iOS
  • 處理權限狀態
  • 內建錯誤處理
  • 跨平台一致性

適合對象

  • 需要執行時權限的行動應用程式
  • 尋求快速權限整合的開發者
  • 同時針對 Android 和 iOS 的應用
  • 注重用戶隱私的項目
  • 希望減少樣板程式碼的團隊

使用建議

  • 某些權限需要原生設定
  • 僅限基本權限類型
  • 可能需要為 Windows 進行額外設定
  • 依賴於底層的 PermissionHandler 庫
  • 不支援自定權限群組

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Easy Permission Validator

This package is useful when you need to manage on-demand permissions for both Android and iOS.

pub package

Usage

To use this plugin, add easy_permission_validator as a dependency in your pubspec.yaml file.

Base use:

_permissionRequest() async {
  final permissionValidator = EasyPermissionValidator(
    context: context,
    appName: 'Easy Permission Validator',
  );
  var result = await permissionValidator.camera();
  if (result) {
    // Do something;
  }
}

You can add custom messages for other languages:

_permissionRequest() async {
  final permissionValidator = EasyPermissionValidator(
    context: context,
    appName: 'Easy Permission Validator',
    appNameColor: Colors.red,
    cancelText: 'Cancelar',
    enableLocationMessage:
        'Debe habilitar los permisos necesarios para utilizar la acción.',
    goToSettingsText: 'Ir a Configuraciones',
    permissionSettingsMessage:
        'Necesita habilitar los permisos necesarios para que la aplicación funcione correctamente',
  );
  var result = await permissionValidator.camera();
  if (result) {
    // Do something;
  }
}

In addition, you can add a custom Dialog:

_permissionWithCustomPopup() async {
  final permissionValidator = EasyPermissionValidator(
    context: context,
    appName: 'Easy Permission Validator',
    customDialog: MyAmazingCustomPopup(),
  );
  var result = await permissionValidator.camera();
  if (result) {
    // Do something;
  }
}

Caution

Some permissions must be in the privacy policy

Permissions

If you use any permissions from this package, you must add:

For iOS (add in ios/Runner/Info.plist):

  <!-- Permission options for the `location` group -->
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>Need location when in use</string>
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>Always and when in use!</string>
  <key>NSLocationUsageDescription</key>
  <string>Older devices need location.</string>
  <key>NSLocationAlwaysUsageDescription</key>
  <string>Can I have location always?</string>

  <!-- Permission options for the `mediaLibrary` group -->
  <key>NSAppleMusicUsageDescription</key>
  <string>Music!</string>
  <key>kTCCServiceMediaLibrary</key>
  <string>media</string>

  <!-- Permission options for the `calendar` group -->
  <key>NSCalendarsUsageDescription</key>
  <string>Calendars</string>
  <key>NSCalendarsFullAccessUsageDescription</key>
  <string>Calendar full access</string>

  <!-- Permission options for the `camera` group -->
  <key>NSCameraUsageDescription</key>
  <string>camera</string>

  <!-- Permission options for the `contacts` group -->
  <key>NSContactsUsageDescription</key>
  <string>contacts</string>

  <!-- Permission options for the `microphone` group -->
  <key>NSMicrophoneUsageDescription</key>
  <string>microphone</string>

  <!-- Permission options for the `speech` group -->
  <key>NSSpeechRecognitionUsageDescription</key>
  <string>speech</string>

  <!-- Permission options for the `sensors` group -->
  <key>NSMotionUsageDescription</key>
  <string>motion</string>

  <!-- Permission options for the `photos` group -->
  <key>NSPhotoLibraryUsageDescription</key>
  <string>photos</string>

  <!-- Permission options for the `reminder` group -->
  <key>NSRemindersUsageDescription</key>
  <string>reminders</string>

  <!-- Permission options for the `bluetooth` -->
  <key>NSBluetoothAlwaysUsageDescription</key>
  <string>bluetooth</string>
  <key>NSBluetoothPeripheralUsageDescription</key>
  <string>bluetooth</string>

  <!-- Permission options for the `appTrackingTransparency` -->
  <key>NSUserTrackingUsageDescription</key>
  <string>appTrackingTransparency</string>

  <!-- Permission options for the `assistant` group -->
  <key>NSSiriUsageDescription</key>
  <string>The example app would like access to Siri Kit to demonstrate requesting authorization.</string>

For ANDROID (add in android/app/src/main/AndroidManifest.xml):

Permissions on Android

  <!--
  Internet permissions do not affect the `permission_handler` plugin, but are required if your app needs access to
  the internet.
  -->
  <uses-permission android:name="android.permission.INTERNET"/>

  <!-- Permissions options for the `contacts` group -->
  <uses-permission android:name="android.permission.READ_CONTACTS"/>
  <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
  <uses-permission android:name="android.permission.GET_ACCOUNTS"/>

  <!-- Permissions options for the `storage` group -->
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <!-- Read storage permission for Android 12 and lower -->
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  <!--
    Granular media permissions for Android 13 and newer.
    See https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions
    for more information.
  -->
  <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
  <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
  <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

  <!-- Permissions options for the `camera` group -->
  <uses-permission android:name="android.permission.CAMERA"/>

  <!-- Permissions options for the `sms` group -->
  <uses-permission android:name="android.permission.SEND_SMS"/>
  <uses-permission android:name="android.permission.RECEIVE_SMS"/>
  <uses-permission android:name="android.permission.READ_SMS"/>
  <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>
  <uses-permission android:name="android.permission.RECEIVE_MMS"/>

  <!-- Permissions options for the `phone` group -->
  <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  <uses-permission android:name="android.permission.CALL_PHONE"/>
  <uses-permission android:name="android.permission.ADD_VOICEMAIL"/>
  <uses-permission android:name="android.permission.USE_SIP"/>
  <uses-permission android:name="android.permission.READ_CALL_LOG"/>
  <uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
  <uses-permission android:name="android.permission.BIND_CALL_REDIRECTION_SERVICE"/>

  <!-- Permissions options for the `calendar` group -->
  <uses-permission android:name="android.permission.READ_CALENDAR" />
  <uses-permission android:name="android.permission.WRITE_CALENDAR" />

  <!-- Permissions options for the `location` group -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

  <!-- Permissions options for the `microphone` or `speech` group -->
  <uses-permission android:name="android.permission.RECORD_AUDIO" />

  <!-- Permissions options for the `sensors` group -->
  <uses-permission android:name="android.permission.BODY_SENSORS" />
  <uses-permission android:name="android.permission.BODY_SENSORS_BACKGROUND" />

  <!-- Permissions options for the `accessMediaLocation` group -->
  <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />

  <!-- Permissions options for the `activityRecognition` group -->
  <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

  <!-- Permissions options for the `ignoreBatteryOptimizations` group -->
  <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

  <!-- Permissions options for the `nearby devices` group -->
  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  <uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" />

  <!-- Permissions options for the `manage external storage` group -->
  <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

  <!-- Permissions options for the `system alert windows` group -->
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

  <!-- Permissions options for the `request install packages` group -->
  <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

  <!-- Permissions options for the `access notification policy` group -->
  <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>

  <!-- Permissions options for the `notification` group -->
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

  <!-- Permissions options for the `alarm` group -->
  <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

Issues

Please file any issues, bugs or feature request as an issue on our GitHub page.

Contributions

You can contribute by making a pull request, this package was made for the community and you have complete power to add whatever they find useful.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。