### Enable Calendar Permission in Podfile Source: https://pub.dev/documentation/permission_handler/latest/index.html Example of enabling a specific permission by setting the corresponding macro to 1. ```ruby ## dart: PermissionGroup.calendar 'PERMISSION_EVENTS=1', ``` -------------------------------- ### hashCode Property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/hashCode.html Explains the hashCode property, its relationship with the operator ==, and provides an implementation example. ```APIDOC ## hashCode Property ### Description The `hashCode` property returns a hash code, which is a single integer representing the object's state that affects equality comparisons. It is crucial for objects used in hash-based data structures like Sets and Maps. ### Method `get hashCode` ### Parameters None ### Request Body None ### Request Example None ### Response #### Success Response (200) - **hashCode** (int) - The hash code of the object. ### Response Example None ### Implementation ```dart @override int get hashCode => value.hashCode; ``` ### Notes - If the `operator ==` is overridden, the `hashCode` must also be overridden to maintain consistency. - Objects that are equal according to `operator ==` must have the same `hashCode`. - The `hashCode` of an object should only change if the object's state affecting equality changes. - While unequal objects can have the same `hashCode`, frequent collisions can reduce the efficiency of hash-based data structures. ``` -------------------------------- ### GET isNotApplicable Property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/ServiceStatusGetters/isNotApplicable.html Retrieves the boolean status indicating if a permission is not applicable on the current platform. ```APIDOC ## GET isNotApplicable ### Description Checks if the permission does not have an associated service on the current platform. ### Method GET ### Response #### Success Response (200) - **isNotApplicable** (bool) - Returns true if the permission is not applicable, false otherwise. ``` -------------------------------- ### GET isLimited Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionCheckShortcuts/isLimited.html Retrieves the limited access status for the application. ```APIDOC ## GET isLimited ### Description Checks if the user has authorized the application for limited access. This property is only supported on iOS (iOS 14+ for photos, iOS 18+ for contacts). ### Method GET ### Response - **isLimited** (bool) - Returns true if the user has granted limited access, false otherwise. ``` -------------------------------- ### GET isNotApplicable Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FutureServiceStatusGetters/isNotApplicable.html Retrieves the boolean status indicating if a permission is applicable on the current platform. ```APIDOC ## GET isNotApplicable ### Description Checks if the permission does not have an associated service on the current platform. ### Method GET ### Endpoint /permission/isNotApplicable ### Response #### Success Response (200) - **isNotApplicable** (bool) - Returns true if the permission is not applicable on the current platform, false otherwise. ``` -------------------------------- ### GET status property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/status.html Retrieves the current PermissionStatus for a specific permission. ```APIDOC ## GET status ### Description Checks the current status of the given Permission. ### Method GET ### Endpoint Permission.status ### Notes - **Permission.bluetooth** (iOS 13.0 only): The method will always return PermissionStatus.denied. Use Permission.bluetooth.request to check the actual state, noting that this may trigger a permission dialog. ``` -------------------------------- ### Get isDenied Property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FuturePermissionStatusGetters/isDenied.html Use this to check if the user has denied access to the requested feature. Ensure the Permission Handler is properly initialized. ```dart Future get isDenied async => (await this).isDenied; ``` -------------------------------- ### GET isProvisional Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FuturePermissionStatusGetters/isProvisional.html Retrieves the provisional authorization status for notifications on iOS. ```APIDOC ## GET isProvisional ### Description Checks if the application is provisionally authorized to post non-interruptive user notifications. This property is only supported on iOS (iOS 12+). ### Method GET ### Endpoint isProvisional ### Response - **isProvisional** (bool) - Returns true if the application is provisionally authorized, false otherwise. ``` -------------------------------- ### GET isEnabled Property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/ServiceStatusGetters/isEnabled.html Checks if the service for the permission is enabled. ```APIDOC ## GET isEnabled ### Description Returns a boolean value indicating whether the service for the permission is enabled. ### Method GET ### Response - **isEnabled** (bool) - True if the service is enabled, false otherwise. ``` -------------------------------- ### GET /permission/status Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission-class.html Checks the current status of a specific permission. ```APIDOC ## GET /permission/status ### Description Checks the current status of the given Permission. ### Method GET ### Response #### Success Response (200) - **status** (PermissionStatus) - The current status of the permission. ``` -------------------------------- ### Sensors Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/sensors-constant.html This section describes the permission constant for accessing device sensors. It specifies the Android and iOS equivalents and provides an implementation example. ```APIDOC ## Sensors Permission ### Description Permission for accessing the device's sensors. This includes Body Sensors on Android and CoreMotion on iOS. ### Implementation ```dart static const sensors = Permission._(12); ``` ``` -------------------------------- ### GET serviceStatus Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/ServicePermissionActions.html Retrieves the current status of the service associated with a specific permission. ```APIDOC ## GET serviceStatus ### Description Checks the current status of the service associated with the given PermissionWithService. ### Method GET ### Endpoint serviceStatus ### Response #### Success Response (200) - **serviceStatus** (Future) - The current status of the associated service. ``` -------------------------------- ### GET shouldShowRequestRationale Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/shouldShowRequestRationale.html Retrieves a boolean indicating whether a rationale should be shown for a specific permission request. This property is platform-specific to Android. ```APIDOC ## GET shouldShowRequestRationale ### Description Checks if the application should show a rationale for requesting a specific permission. This is primarily used to explain to the user why a permission is needed before triggering the system dialog. ### Method GET ### Endpoint shouldShowRequestRationale ### Response #### Success Response (200) - **result** (bool) - Returns true if a rationale should be shown, false otherwise. On iOS, this always returns false. ``` -------------------------------- ### Set Callback for Permanently Denied Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/onPermanentlyDeniedCallback.html Use this method to register a callback function that will be executed when a permission is permanently denied. This allows for custom handling, such as guiding the user to app settings. ```dart Permission onPermanentlyDeniedCallback(FutureOr? Function()? callback) { _onPermanentlyDenied = callback; return this; } ``` -------------------------------- ### GET isEnabled Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FutureServiceStatusGetters/isEnabled.html Retrieves the current status of a permission service to determine if it is enabled. ```APIDOC ## GET isEnabled ### Description Checks if the service for the permission is enabled. ### Method GET ### Endpoint isEnabled ### Response #### Success Response (200) - **isEnabled** (bool) - Returns true if the service is enabled, false otherwise. ``` -------------------------------- ### openAppSettings() Source: https://pub.dev/documentation/permission_handler/latest/permission_handler Opens the application settings page on the device. ```APIDOC ## openAppSettings() ### Description Opens the app settings page for the current application. ### Method Function Call ### Response - **Future** - Returns true if the settings page was opened successfully, false otherwise. ``` -------------------------------- ### openAppSettings function Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/openAppSettings.html Documentation for the function that navigates the user to the application settings page. ```APIDOC ## openAppSettings ### Description Opens the app settings page for the current application. ### Method Function Call ### Returns - **bool** - Returns true if the app settings page could be opened, otherwise false. ### Implementation ```dart Future openAppSettings() => _handler.openAppSettings(); ``` ``` -------------------------------- ### Open App Settings Source: https://pub.dev/documentation/permission_handler/latest/index.html Redirect the user to system settings when a permission is permanently denied. ```dart if (await Permission.speech.isPermanentlyDenied) { // The user opted to never again see the permission request dialog for this // app. The only way to change the permission's status now is to let the // user manually enables it in the system settings. openAppSettings(); } ``` -------------------------------- ### PermissionWithService Class Overview Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService-class.html Provides an overview of the PermissionWithService class, its inheritance, and available extensions. ```APIDOC ## PermissionWithService Class A special kind of permission, used to access a service. Additionally to the actions that normal Permissions have, you can also query the status of the related service. ### Inheritance * Object * Permission * PermissionWithService ### Available extensions * PermissionActions * PermissionCheckShortcuts * ServicePermissionActions ``` -------------------------------- ### Configure iOS Permissions in Podfile Source: https://pub.dev/documentation/permission_handler/latest/index.html Use GCC preprocessor definitions in the Podfile to enable or disable specific permission groups for the iOS build. ```ruby post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| # You can remove unused permissions here # for more information: https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [ '$(inherited)', ## dart: PermissionGroup.calendar 'PERMISSION_EVENTS=1', ## dart: PermissionGroup.calendarFullAccess 'PERMISSION_EVENTS_FULL_ACCESS=1', ## dart: PermissionGroup.reminders 'PERMISSION_REMINDERS=1', ## dart: PermissionGroup.contacts 'PERMISSION_CONTACTS=1', ## dart: PermissionGroup.camera 'PERMISSION_CAMERA=1', ## dart: PermissionGroup.microphone 'PERMISSION_MICROPHONE=1', ## dart: PermissionGroup.speech 'PERMISSION_SPEECH_RECOGNIZER=1', ## dart: PermissionGroup.photos 'PERMISSION_PHOTOS=1', ## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If ## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE` ## macro. ## ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse] 'PERMISSION_LOCATION=1', 'PERMISSION_LOCATION_WHENINUSE=0', ## dart: PermissionGroup.notification 'PERMISSION_NOTIFICATIONS=1', ## dart: PermissionGroup.mediaLibrary 'PERMISSION_MEDIA_LIBRARY=1', ## dart: PermissionGroup.sensors 'PERMISSION_SENSORS=1', ## dart: PermissionGroup.bluetooth 'PERMISSION_BLUETOOTH=1', ## dart: PermissionGroup.appTrackingTransparency 'PERMISSION_APP_TRACKING_TRANSPARENCY=1', ## dart: PermissionGroup.criticalAlerts 'PERMISSION_CRITICAL_ALERTS=1', ## dart: PermissionGroup.assistant 'PERMISSION_ASSISTANT=1', ] end end end ``` -------------------------------- ### PermissionWithService Constructors Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService-class.html Details on how to construct a PermissionWithService object. ```APIDOC ## Constructors ### PermissionWithService.private(int value) Creates a PermissionWithService instance. ```dart const PermissionWithService.private(int value) ``` ``` -------------------------------- ### GET isPermanentlyDenied Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FuturePermissionStatusGetters/isPermanentlyDenied.html Retrieves the status of a permission to determine if it has been permanently denied by the user. ```APIDOC ## GET isPermanentlyDenied ### Description Checks if the permission to the requested feature is permanently denied. If true, the permission dialog will not be shown when requesting this permission, and the user must change the status via system settings. ### Method GET ### Endpoint Permission.isPermanentlyDenied ### Platform Behavior - **Android 11+ (API 30+)**: Returns true if the user denied the permission for a second time. - **Android < 11**: Returns true if the user denied access and selected 'never again show a request'. - **iOS**: Returns true if the user has denied access to the requested feature. ### Response - **isPermanentlyDenied** (bool) - Returns true if the permission is permanently denied, false otherwise. ``` -------------------------------- ### Open App Settings Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/openAppSettings.html Opens the app settings page. Returns `true` if the app settings page could be opened, otherwise `false`. ```dart Future openAppSettings() => _handler.openAppSettings(); ``` -------------------------------- ### request() Method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionListActions.html Requests the user for access to a list of permissions, if they haven't already been granted before. ```APIDOC ## request() ### Description Requests the user for access to a list of permissions, if they haven't already been granted before. ### Method N/A (Extension Method) ### Parameters - **List** - Required - The list of permissions to request. ### Response - **Future>** - A map containing the resulting status for each requested permission. ``` -------------------------------- ### GET isRestricted Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionCheckShortcuts/isRestricted.html Checks if the OS has restricted the permission, preventing the user from changing its status. ```APIDOC ## GET isRestricted ### Description Checks if the OS denied this permission. The user cannot change the status, possibly due to active restrictions such as parental controls being in place. Only supported on iOS. ### Method GET ### Endpoint /isRestricted ### Response #### Success Response (200) - **isRestricted** (bool) - Returns true if the permission is restricted by the OS, false otherwise. ``` -------------------------------- ### GET isDisabled property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FutureServiceStatusGetters/isDisabled.html Retrieves the status of a permission service to determine if it is currently disabled. ```APIDOC ## GET isDisabled ### Description Checks if the service for the permission is disabled. ### Method GET ### Endpoint isDisabled ### Response - **isDisabled** (bool) - Returns true if the service is disabled, false otherwise. ``` -------------------------------- ### Show Permission Rationale Source: https://pub.dev/documentation/permission_handler/latest/index.html Check if the OS suggests showing a rationale for a permission request on Android. ```dart bool isShown = await Permission.contacts.shouldShowRequestRationale; ``` -------------------------------- ### Implement PermissionWithService.private constructor Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService/PermissionWithService.private.html This constructor is marked with @visibleForTesting and should only be used in test environments. ```dart @visibleForTesting const PermissionWithService.private(super.value) : super._(); ``` -------------------------------- ### Bluetooth Connect Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/bluetoothConnect-constant.html Information about the bluetoothConnect permission constant. ```APIDOC ## Permission bluetoothConnect ### Description Permission for connecting to Bluetooth devices. Requires Android 12+ (API 31+). ### Platform Availability - Android 12+ (API 31+) ### Purpose Allows the user to connect with already paired Bluetooth devices. ### Implementation ```dart static const bluetoothConnect = Permission._(30); ``` ``` -------------------------------- ### Handle Permission Callbacks Source: https://pub.dev/documentation/permission_handler/latest/index.html Use a fluent API to define callbacks for different permission states before requesting access. ```dart await Permission.camera .onDeniedCallback(() { // Your code }) .onGrantedCallback(() { // Your code }) .onPermanentlyDeniedCallback(() { // Your code }) .onRestrictedCallback(() { // Your code }) .onLimitedCallback(() { // Your code }) .onProvisionalCallback(() { // Your code }) .request(); ``` -------------------------------- ### Get isProvisional Status Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FuturePermissionStatusGetters/isProvisional.html Retrieve the provisional authorization status for notifications. Only supported on iOS 12+. ```dart Future get isProvisional async => (await this).isProvisional; ``` -------------------------------- ### Define requestInstallPackages constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/requestInstallPackages-constant.html The constant is defined as a Permission object with an internal identifier of 24. ```dart static const requestInstallPackages = Permission._(24); ``` -------------------------------- ### Configure AndroidX in gradle.properties Source: https://pub.dev/documentation/permission_handler/latest/index.html Enable AndroidX and Jetifier to ensure compatibility with modern Android support libraries. ```properties android.useAndroidX=true android.enableJetifier=true ``` -------------------------------- ### Implement Permission Request Logic Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/request.html Use this method to request user permission. It handles various permission statuses including denied, granted, permanently denied, restricted, limited, and provisional, and invokes corresponding callbacks. ```dart Future request() async { final permissionStatus = (await [this].request())[this] ?? PermissionStatus.denied; if (permissionStatus.isDenied) { _onDenied?.call(); } else if (permissionStatus.isGranted) { _onGranted?.call(); } else if (permissionStatus.isPermanentlyDenied) { _onPermanentlyDenied?.call(); } else if (permissionStatus.isRestricted) { _onRestricted?.call(); } else if (permissionStatus.isLimited) { _onLimited?.call(); } else if (permissionStatus.isProvisional) { _onProvisional?.call(); } return permissionStatus; } ``` -------------------------------- ### PermissionWithService Methods Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService-class.html Details on the methods available for PermissionWithService objects. ```APIDOC ## Methods ### noSuchMethod(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. ### onDeniedCallback(FutureOr? callback()?) → Permission Method to set a callback for when permission is denied. ### onGrantedCallback(FutureOr? callback()?) → Permission Method to set a callback for when permission is granted. ### onLimitedCallback(FutureOr? callback()?) → Permission Method to set a callback for when permission is limited. ### onPermanentlyDeniedCallback(FutureOr? callback()?) → Permission Method to set a callback for when permission is permanently denied. ### onProvisionalCallback(FutureOr? callback()?) → Permission Method to set a callback for when permission is provisional. ### onRestrictedCallback(FutureOr? callback()?) → Permission Method to set a callback for when permission is restricted. ### request() → Future Request the user for access to this Permission, if access hasn't already been grant access before. ### toString() → String A string representation of this object. ``` -------------------------------- ### PermissionWithService Private Constructor Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService/PermissionWithService.private.html Details the private constructor for PermissionWithService, which is visible for testing purposes. ```APIDOC ## PermissionWithService.private constructor ### Description Creates a PermissionWithService instance. This constructor is marked public for testing purposes only. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## Implementation ```dart @visibleForTesting const PermissionWithService.private(super.value) : super._(); ``` ``` -------------------------------- ### Get isRestricted Status Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/FuturePermissionStatusGetters/isRestricted.html Retrieves the restricted status of the permission. Only supported on iOS. Use this when you need to check if the user is unable to grant permission due to system-level restrictions. ```dart Future get isRestricted async => (await this).isRestricted; ``` -------------------------------- ### request() Method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionListActions/request.html Requests the user for access to specific permissions if they have not been granted previously. ```APIDOC ## request() ### Description Requests the user for access to these permissions, if they haven't already been granted before. Returns a Map containing the status per requested Permission. ### Method Future> request() ### Response - **Map** - A map containing the status per requested Permission. ``` -------------------------------- ### request() Method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/request.html Requests the user for access to a specific permission and returns the updated status. ```APIDOC ## request() ### Description Requests the user for access to this Permission, if access hasn't already been granted before. Returns the new PermissionStatus. ### Response - **PermissionStatus** (enum) - The resulting status of the permission request (e.g., granted, denied, permanentlyDenied, restricted, limited, provisional). ``` -------------------------------- ### toString Method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/toString.html Provides a string representation of the Permission object, useful for debugging and logging. ```APIDOC ## toString Method ### Description Returns a string representation of the Permission object. This is primarily used for debugging or logging purposes. ### Method `toString()` ### Endpoint N/A (This is a method within a class, not an API endpoint) ### Parameters None ### Request Example N/A ### Response #### Success Response (String) - **String** - A string representation of the Permission object (e.g., 'Permission.GRANTED'). #### Response Example ``` "Permission.GRANTED" ``` ### Implementation ```dart @override String toString() => 'Permission.${_names[value]}'; ``` ``` -------------------------------- ### PermissionWithService Properties Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService-class.html Lists and describes the properties available for PermissionWithService objects. ```APIDOC ## Properties ### hashCode → int The hash code for this object. ### isDenied → Future If the user denied this permission. ### isGranted → Future If the user granted this permission. ### isLimited → Future User has authorized this application for limited access. _Only supported on iOS._ ### isPermanentlyDenied → Future Returns `true` when permissions are denied permanently. ### isProvisional → Future If the application is provisionally authorized to post noninterruptive user notifications. _Only supported on iOS._ ### isRestricted → Future If the OS denied this permission. The user cannot change the status, possibly due to active restrictions such as parental controls being in place. _Only supported on iOS._ ### runtimeType → Type A representation of the runtime type of the object. ### serviceStatus → Future Checks the current status of the service associated with the given Permission. ### shouldShowRequestRationale → Future If you should show a rationale for requesting permission. ### status → Future Checks the current status of the given Permission. ### value → int Integer representation of the Permission. ``` -------------------------------- ### onProvisionalCallback method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/onProvisionalCallback.html Sets a callback function to be executed when a permission is in a provisional state. ```APIDOC ## onProvisionalCallback ### Description Sets a callback for when a permission is provisional. This method returns the Permission instance to allow for method chaining. ### Parameters - **callback** (FutureOr? Function()?) - Required - The function to be executed when the permission is provisional. ### Implementation ```dart Permission onProvisionalCallback(FutureOr? Function()? callback) { _onProvisional = callback; return this; } ``` ``` -------------------------------- ### Define Permission.photos constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/photos-constant.html The internal definition of the photos permission constant. ```dart static const photos = Permission._(9); ``` -------------------------------- ### Microphone Permission Constant Implementation Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/microphone-constant.html Defines the static constant for microphone permission. ```dart static const microphone = Permission._(7); ``` -------------------------------- ### Define systemAlertWindow constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/systemAlertWindow-constant.html The constant definition for the system alert window permission. ```dart static const systemAlertWindow = Permission._(23); ``` -------------------------------- ### scheduleExactAlarm Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/scheduleExactAlarm-constant.html Information about the scheduleExactAlarm permission. ```APIDOC ## Permission: scheduleExactAlarm ### Description Permission for scheduling exact alarms. This is required for applications targeting Android 12 (API level 31) and higher. ### Implementation ```dart static const scheduleExactAlarm = Permission._(34); ``` ``` -------------------------------- ### POST /permission/request Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission-class.html Requests the user for access to a specific permission. ```APIDOC ## POST /permission/request ### Description Request the user for access to this Permission, if access hasn't already been granted. ### Method POST ### Response #### Success Response (200) - **status** (PermissionStatus) - The resulting status after the request. ``` -------------------------------- ### Bluetooth Advertise Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/bluetoothAdvertise-constant.html Information about the `bluetoothAdvertise` permission. ```APIDOC ## Bluetooth Advertise Permission ### Description Permission for advertising Bluetooth devices. This permission is required for Android 12+ (API 31+) to allow the user to make this device discoverable to other Bluetooth devices. ### Implementation ```dart static const bluetoothAdvertise = Permission._(29); ``` ``` -------------------------------- ### Permission Constants Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission-class.html This section details the various permission constants available in the permission_handler package. Each constant represents a specific permission that can be requested on a mobile device. ```APIDOC ## Permission Constants Overview This document outlines the available permission constants within the `permission_handler` package. These constants are used to request specific permissions from the user on both Android and iOS platforms. ### Accessing Permissions Permissions are typically requested using methods provided by the `PermissionHandler` class, which are not detailed in this specific documentation excerpt. The constants listed below are used as arguments to these request methods. ### Available Permissions - **accessMediaLocation** (Permission): Permission for accessing the device's media library. - **accessNotificationPolicy** (Permission): Permission for accessing the device's notification policy. - **activityRecognition** (Permission): Permission for accessing the activity recognition. - **appTrackingTransparency** (Permission): Permission for accessing the device's tracking state (iOS only). - **assistant** (Permission): Android: Nothing, iOS: SiriKit. - **audio** (Permission): Permission for accessing the device's audio files from external storage. - **backgroundRefresh** (Permission): Permission for reading the current background refresh status. (iOS only) - **bluetooth** (PermissionWithService): Permission for accessing the device's bluetooth adapter state. - **bluetoothAdvertise** (Permission): Permission for advertising Bluetooth devices. - **bluetoothConnect** (Permission): Permission for connecting to Bluetooth devices. - **bluetoothScan** (Permission): Permission for scanning for Bluetooth devices. - **calendar** (Permission): Permission for accessing the device's calendar. - **calendarFullAccess** (Permission): Permission for reading from and writing to the device's calendar. - **calendarWriteOnly** (Permission): Permission for writing to the device's calendar. - **camera** (Permission): Permission for accessing the device's camera. - **contacts** (Permission): Permission for accessing the device's contacts. - **criticalAlerts** (Permission): Permission for sending critical alerts (iOS only). - **ignoreBatteryOptimizations** (Permission): Permission for accessing ignore battery optimizations (Android only). - **location** (PermissionWithService): Permission for accessing the device's location. - **locationAlways** (PermissionWithService): Permission for accessing the device's location when the app is running in the background. - **locationWhenInUse** (PermissionWithService): Permission for accessing the device's location when the app is running in the foreground. - **manageExternalStorage** (Permission): Permission for accessing the device's external storage. - **mediaLibrary** (Permission): Permission for accessing the device's media library (iOS 9.3+ only). - **microphone** (Permission): Permission for accessing the device's microphone. - **nearbyWifiDevices** (Permission): Permission for connecting to nearby devices via Wi-Fi. - **notification** (Permission): Permission for pushing notifications. - **phone** (PermissionWithService): Permission for accessing the device's phone state (Android only). - **photos** (Permission): Permission for accessing the device's photos. - **photosAddOnly** (Permission): Permission for adding photos to the device's photo library (iOS only). - **reminders** (Permission): Permission for accessing the device's reminders (iOS only). - **requestInstallPackages** (Permission): Permission for requesting installing packages. - **scheduleExactAlarm** (Permission): Permission for scheduling exact alarms. - **sensors** (Permission): Permission for accessing the device's sensors. - **sensorsAlways** (Permission): Permission for accessing the device's sensors in background. - **sms** (Permission): Permission for sending and reading SMS messages (Android only). - **speech** (Permission): Permission for accessing speech recognition. - **storage** (Permission): Permission for accessing external storage. - **systemAlertWindow** (Permission): Permission for creating system alert window (Android only). - **unknown** (Permission): The unknown only used for return type, never requested. - **videos** (Permission): Permission for accessing the device's video files from external storage. ### Special Values - **values** (List): Returns a list of all possible `PermissionGroup` values. ``` -------------------------------- ### Calendar Permissions Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/calendar-constant.html Provides information about the deprecated `calendar` permission constant and its recommended alternatives. ```APIDOC ## Deprecated Calendar Permission ### Description This constant represents permission for accessing the device's calendar. It is deprecated and users should use `calendarWriteOnly` and `calendarFullAccess` instead. ### Platform Availability - Android: Calendar - iOS: Calendar (Events) ### Implementation ```dart @Deprecated('Use [calendarWriteOnly] and [calendarFullAccess].') static const calendar = Permission._(0); ``` ### Recommended Alternatives - `calendarWriteOnly`: For write-only access to the calendar. - `calendarFullAccess`: For full read and write access to the calendar. ``` -------------------------------- ### Define audio permission constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/audio-constant.html Used for accessing audio files on Android 13+ (API 33+). ```dart static const audio = Permission._(33); ``` -------------------------------- ### Request Permissions Source: https://pub.dev/documentation/permission_handler/latest/index.html Request single or multiple permissions and handle the resulting status. ```dart if (await Permission.contacts.request().isGranted) { // Either the permission was already granted before or the user just granted it. } // You can request multiple permissions at once. Map statuses = await [ Permission.location, Permission.storage, ].request(); print(statuses[Permission.location]); ``` -------------------------------- ### Define camera permission constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/camera-constant.html Represents the camera permission with an internal identifier. ```dart static const camera = Permission._(1); ``` -------------------------------- ### ignoreBatteryOptimizations Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/ignoreBatteryOptimizations-constant.html Details regarding the ignoreBatteryOptimizations permission constant. ```APIDOC ## ignoreBatteryOptimizations ### Description Permission for accessing ignore battery optimizations (Android only). ### Implementation ```dart static const ignoreBatteryOptimizations = Permission._(16); ``` ``` -------------------------------- ### Permission.camera Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/camera-constant.html Defines the camera permission constant used to request access to the device's camera. ```APIDOC ## Permission.camera ### Description Permission for accessing the device's camera. ### Platform Behavior - **Android**: Camera - **iOS**: Photos (Camera Roll and Camera) ### Implementation ```dart static const camera = Permission._(1); ``` ``` -------------------------------- ### Define accessMediaLocation constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/accessMediaLocation-constant.html The constant definition for accessing device media location permissions. ```dart static const accessMediaLocation = Permission._(18); ``` -------------------------------- ### App Tracking Transparency Permission Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/appTrackingTransparency-constant.html Defines the constant for the appTrackingTransparency permission. ```APIDOC ## App Tracking Transparency Permission ### Description Permission for accessing the device's tracking state (iOS only). Allows the user to accept that your app collects data about end users and shares it with other companies for purposes of tracking across apps and websites. ### Implementation ```dart static const appTrackingTransparency = Permission._(25); ``` ``` -------------------------------- ### Permission.byValue Constructor Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/Permission.byValue.html Creates a Permission object using a supplied integer value. This is a factory constructor that maps an integer to a predefined Permission value. ```APIDOC ## Permission.byValue Constructor ### Description Creates a Permission using the supplied integer value. ### Method Factory Constructor ### Endpoint N/A (Dart class constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart // Example of how to use the constructor (conceptual) // Permission myPermission = Permission.byValue(1); ``` ### Response #### Success Response (200) - **Permission** (Permission) - The Permission object corresponding to the input value. #### Response Example ```json { "example": "// Dart code example, not JSON response" } ``` ### Implementation ```dart factory Permission.byValue(int value) => values[value]; ``` ``` -------------------------------- ### Define Media Library Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/mediaLibrary-constant.html This constant represents the permission for accessing the device's media library. It is only applicable for iOS 9.3 and later. ```dart static const mediaLibrary = Permission._(6); ``` -------------------------------- ### systemAlertWindow Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/systemAlertWindow-constant.html Details regarding the systemAlertWindow permission constant used for Android system overlay functionality. ```APIDOC ## systemAlertWindow ### Description Permission for creating system alert windows (Android only). Allows an app to create windows shown on top of all other apps. ### Implementation ```dart static const systemAlertWindow = Permission._(23); ``` ``` -------------------------------- ### Implementation of shouldShowRequestRationale Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/shouldShowRequestRationale.html This property returns a boolean indicating if a rationale is required. It is only functional on Android and returns false on iOS. ```dart Future get shouldShowRequestRationale async { if (defaultTargetPlatform != TargetPlatform.android) { return false; } return _handler.shouldShowRequestPermissionRationale(this); } ``` -------------------------------- ### Configure Android Manifest permissions Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/photos-constant.html Required manifest entries for handling photo permissions across different Android API levels. ```xml ``` -------------------------------- ### Permission Constants Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/assistant-constant.html Defines constants for permissions, including platform-specific values. ```APIDOC ## Permission Constants ### Description Provides constants for various permissions, with specific implementations for Android and iOS. ### Android - **Nothing**: No specific permission constant mentioned. ### iOS - **SiriKit**: Represents the SiriKit permission. ### Implementation ```dart static const assistant = Permission._(38); ``` ### Request Body This section is not applicable as it refers to constants and implementation details, not API requests. ``` -------------------------------- ### LocationWhenInUse Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/locationWhenInUse-constant.html Details about the `locationWhenInUse` permission constant, which allows access to the device's location when the app is running in the foreground. ```APIDOC ## PermissionWithService locationWhenInUse ### Description Permission for accessing the device's location when the app is running in the foreground. **Android:** Fine and Coarse Location **iOS:** CoreLocation - WhenInUse ### Implementation ```dart static const locationWhenInUse = PermissionWithService._(5); ``` ``` -------------------------------- ### Set Provisional Permission Callback Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/onProvisionalCallback.html Use this method to register a callback function that will be executed when a permission state becomes provisional. The callback is optional. ```dart Permission onProvisionalCallback(FutureOr? Function()? callback) { _onProvisional = callback; return this; } ``` -------------------------------- ### Define Permission.assistant constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/assistant-constant.html Represents the assistant permission constant. This is supported on Android and iOS (SiriKit). ```dart static const assistant = Permission._(38); ``` -------------------------------- ### Permission Methods Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions.html Methods available on a Permission object through the PermissionActions extension for managing callbacks and requesting permissions. ```APIDOC ## Permission Methods ### onDeniedCallback - **Parameters**: `callback` (FutureOr?) - **Returns**: `Permission` - **Description**: Sets a callback function to be executed when the permission is denied. ### onGrantedCallback - **Parameters**: `callback` (FutureOr?) - **Returns**: `Permission` - **Description**: Sets a callback function to be executed when the permission is granted. ### onLimitedCallback - **Parameters**: `callback` (FutureOr?) - **Returns**: `Permission` - **Description**: Sets a callback function to be executed when the permission is limited. ### onPermanentlyDeniedCallback - **Parameters**: `callback` (FutureOr?) - **Returns**: `Permission` - **Description**: Sets a callback function to be executed when the permission is permanently denied. ### onProvisionalCallback - **Parameters**: `callback` (FutureOr?) - **Returns**: `Permission` - **Description**: Sets a callback function to be executed when the permission is provisional. ### onRestrictedCallback - **Parameters**: `callback` (FutureOr?) - **Returns**: `Permission` - **Description**: Sets a callback function to be executed when the permission is restricted. ### request - **Returns**: `Future` - **Description**: Requests the user for access to this permission if access has not already been granted. ``` -------------------------------- ### Accessing all Permission values Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/values-constant.html Use this constant to retrieve a complete list of all defined Permission types. ```dart static const List values = [ // ignore: deprecated_member_use_from_same_package calendar, camera, contacts, location, locationAlways, locationWhenInUse, mediaLibrary, microphone, phone, photos, photosAddOnly, reminders, sensors, sms, speech, storage, ignoreBatteryOptimizations, notification, accessMediaLocation, activityRecognition, unknown, bluetooth, manageExternalStorage, systemAlertWindow, requestInstallPackages, appTrackingTransparency, criticalAlerts, accessNotificationPolicy, bluetoothScan, bluetoothAdvertise, bluetoothConnect, nearbyWifiDevices, videos, audio, scheduleExactAlarm, sensorsAlways, calendarWriteOnly, calendarFullAccess, assistant, backgroundRefresh, ]; ``` -------------------------------- ### PermissionWithService Operators Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionWithService-class.html Details on the operators available for PermissionWithService objects. ```APIDOC ## Operators ### operator ==(Object other) → bool The equality operator. ``` -------------------------------- ### calendarFullAccess Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/calendarFullAccess-constant.html Defines the constant for full calendar access permission. ```APIDOC ## Permission: calendarFullAccess ### Description Permission for reading from and writing to the device's calendar. ### Implementation ```dart static const calendarFullAccess = Permission._(37); ``` ``` -------------------------------- ### Permission.locationAlways Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/locationAlways-constant.html Handles the permission for accessing the device's location when the app is running in the background. ```APIDOC ## Permission.locationAlways ### Description Permission for accessing the device's location when the app is running in the background. ### Platform Specifics **Android:** * **API 29 and above:** Requires Background Location Permission. To request this, the user must first grant foreground location permissions (using `Permission.location` or `Permission.locationWhenInUse`). Requesting `Permission.locationAlways` will then prompt an additional dialog or open settings to allow 'allow all the time' location access. * **Below API 29:** Requires Fine and Coarse Location permissions. **iOS:** * Requires CoreLocation - Always permission. ### Implementation ```dart static const locationAlways = PermissionWithService._(4); ``` ``` -------------------------------- ### Define Videos Permission Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/videos-constant.html This constant is used to represent the permission for accessing the device's video files from external storage. Requires Android 13+ (API 33+). ```dart static const videos = Permission._(32); ``` -------------------------------- ### Nearby Wi-Fi Devices Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/nearbyWifiDevices-constant.html Permission for connecting to nearby devices via Wi-Fi. Requires Android 13+ (API 33+). ```APIDOC ## Permission: nearbyWifiDevices ### Description Permission for connecting to nearby devices via Wi-Fi. ### Platform Android 13+ (API 33+) ### Implementation Example ```dart static const nearbyWifiDevices = Permission._(31); ``` ``` -------------------------------- ### Define Location Always Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/locationAlways-constant.html Defines the constant for the locationAlways permission. This is used internally to represent the permission. ```dart static const locationAlways = PermissionWithService._(4); ``` -------------------------------- ### isDenied property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionStatusGetters/isDenied.html Checks if the current permission status is denied. ```APIDOC ## isDenied property ### Description Returns a boolean value indicating if the user has denied access to the requested feature. ### Property `bool get isDenied` ### Implementation ```dart bool get isDenied => this == PermissionStatus.denied; ``` ``` -------------------------------- ### isDenied Property Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionCheckShortcuts/isDenied.html Checks if the user has denied the permission. ```APIDOC ## isDenied Property ### Description If the user denied this permission. ### Method GET ### Endpoint /websites/pub_dev_permission_handler ### Return Value - **isDenied** (Future) - Returns true if the user denied the permission, false otherwise. ### Implementation ```dart Future get isDenied => status.isDenied; ``` ``` -------------------------------- ### Define Bluetooth Advertise Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/bluetoothAdvertise-constant.html Defines the constant for the Bluetooth Advertise permission. Requires Android 12+ (API 31+). ```dart static const bluetoothAdvertise = Permission._(29); ``` -------------------------------- ### Define Activity Recognition Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/activityRecognition-constant.html Defines the constant for the activity recognition permission. Requires Android 10+ (API 29+). ```dart static const activityRecognition = Permission._(19); ``` -------------------------------- ### Define Reminders Permission Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/reminders-constant.html Use this constant to request permission for accessing the device's reminders on iOS. Ensure the platform is iOS before requesting this permission. ```dart static const reminders = Permission._(11); ``` -------------------------------- ### onLimitedCallback Method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/onLimitedCallback.html Sets a callback function to be executed when a permission status is limited. ```APIDOC ## Method: onLimitedCallback ### Description Sets a callback for when permission is limited. This method returns the Permission instance to allow for method chaining. ### Parameters - **callback** (FutureOr? Function()?) - Required - The function to execute when the permission is limited. ### Implementation ```dart Permission onLimitedCallback(FutureOr? Function()? callback) { _onLimited = callback; return this; } ``` ``` -------------------------------- ### Request permissions implementation Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionListActions/request.html This method triggers the permission request flow and returns a map of statuses. ```dart Future> request() => _handler.requestPermissions(this); ``` -------------------------------- ### Define scheduleExactAlarm constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/scheduleExactAlarm-constant.html The constant definition for the scheduleExactAlarm permission. ```dart static const scheduleExactAlarm = Permission._(34); ``` -------------------------------- ### onGrantedCallback method Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions/onGrantedCallback.html Sets a callback function to be executed when the permission is granted. ```APIDOC ## onGrantedCallback ### Description Method to set a callback for when permission is granted. ### Parameters - **callback** (FutureOr? Function()?) - Optional - The function to execute upon permission grant. ### Implementation ```dart Permission onGrantedCallback(FutureOr? Function()? callback) { _onGranted = callback; return this; } ``` ``` -------------------------------- ### PermissionStatus Enum Values Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionStatus.html Details the possible states a permission can hold within the application. ```APIDOC ## PermissionStatus Enum Values ### Description Defines the state of a Permission. These values represent the outcome of a permission request. ### Values - **denied**: The user denied access to the requested feature, permission needs to be asked first. - **granted**: The user granted access to the requested feature. - **restricted**: The OS denied access to the requested feature. The user cannot change this app's status (e.g., parental controls). *Only supported on iOS.* - **limited**: The user has authorized this application for limited access (e.g., Photo Library). *Supported on iOS14+ and Android 14+.* - **permanentlyDenied**: Permission is permanently denied; the dialog will not be shown. The user must change this in settings. - **provisional**: The application is provisionally authorized to post non-interruptive notifications. *Only supported on iOS12+.* ``` -------------------------------- ### Define Storage Permission Constant Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/storage-constant.html Defines a constant for the storage permission. Note that on Android 13+, this permission is deprecated and specific media permissions should be used instead. ```dart static const storage = Permission._(15); ``` -------------------------------- ### Create Permission from Integer Value Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/Permission.byValue.html Use the factory constructor `Permission.byValue` to create a Permission object from its integer representation. Ensure the integer value exists within the defined permissions. ```dart factory Permission.byValue(int value) => values[value]; ``` -------------------------------- ### Permission Properties Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionActions.html Properties available on a Permission object through the PermissionActions extension. ```APIDOC ## Permission Properties ### shouldShowRequestRationale - **Type**: Future - **Description**: Indicates if a rationale should be shown to the user before requesting permission. - **Setter**: No ### status - **Type**: Future - **Description**: Retrieves the current status of the permission. - **Setter**: No ``` -------------------------------- ### Check photo permission status on Android Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/photos-constant.html Logic to determine whether to check storage or photos permission based on the Android SDK version. ```dart if (Platform.isAndroid) { final androidInfo = await DeviceInfoPlugin().androidInfo; if (androidInfo.version.sdkInt <= 32) { use `Permission.storage.status` } else { use `Permission.photos.status` } } ``` -------------------------------- ### Define calendarFullAccess Permission Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/Permission/calendarFullAccess-constant.html This constant represents the permission for reading from and writing to the device's calendar. It is part of the Permission class. ```dart static const calendarFullAccess = Permission._(37); ``` -------------------------------- ### PermissionStatus Getters Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/PermissionStatus.html Extension methods available on PermissionStatus to check the state of a permission. ```APIDOC ## PermissionStatus Getters ### Description Extension properties provided by PermissionStatusGetters to easily check the status of a permission. ### Properties - **isDenied** (bool): True if the user denied access. - **isGranted** (bool): True if the user granted access. - **isLimited** (bool): True if the user authorized limited access. - **isPermanentlyDenied** (bool): True if the permission is permanently denied. - **isProvisional** (bool): True if the application is provisionally authorized. - **isRestricted** (bool): True if the OS denied access due to restrictions. ``` -------------------------------- ### ServiceStatus Enum Source: https://pub.dev/documentation/permission_handler/latest/permission_handler/ServiceStatus.html Details about the ServiceStatus enum, its inheritance, values, properties, and methods. ```APIDOC ## ServiceStatus Enum ### Description Defines the different states a service can be in. ### Inheritance * Object * Enum * ServiceStatus ### Available extensions * EnumName * ServiceStatusGetters ## Values ### `disabled` `const ServiceStatus` The service for the permission is disabled. ### `enabled` `const ServiceStatus` The service for the permission is enabled. ### `notApplicable` `const ServiceStatus` The permission does not have an associated service on the current platform. ## Properties ### `hashCode` `int` The hash code for this object. `no setter` `inherited` ### `index` `int` A numeric identifier for the enumerated value. `no setter` `inherited` ### `isDisabled` `bool` Available on ServiceStatus, provided by the ServiceStatusGetters extension If the service for the permission is disabled. `no setter` ### `isEnabled` `bool` Available on ServiceStatus, provided by the ServiceStatusGetters extension If the service for the permission is enabled. `no setter` ### `isNotApplicable` `bool` Available on ServiceStatus, provided by the ServiceStatusGetters extension If the permission does not have an associated service on the current platform. `no setter` ### `name` `String` Available on Enum, provided by the EnumName extension The name of the enum value. `no setter` ### `runtimeType` `Type` A representation of the runtime type of the object. `no setter` `inherited` ## Methods ### `noSuchMethod` `(Invocation invocation) → dynamic` Invoked when a nonexistent method or property is accessed. `inherited` ### `toString` `() → String` A string representation of this object. `inherited` ## Operators ### `operator ==` `(Object other) → bool` The equality operator. `inherited` ## Constants ### `values` `const List` A constant List of the values in this enum, in order of their declaration. ```