Commit 384fc9ea by Andrew Brampton Committed by GitHub

Update documentation in permission_status.dart (#1161)

* Update documentation in permission_status.dart

Updated the documentation to be clearer when limited and provisional statuses may be returned. The docs are repeated ~3 times, so I made them consistent.

* Updated the permanentlyDenied description per changes made in version 11.0.0

* Bumped the version in pubspec and CHANGELOG.

---------

Co-authored-by: Maurits van Beusekom <maurits@vnbskm.nl>
parent d97a0822
## 4.0.2
* Improved the documentation around the `PermissionStatus`, `PermissionStatusGetters` and `FuturePermissionStatusGetters`.
## 4.0.1 ## 4.0.1
* Updates Android documentation on how to use `permission.photo` on Android 12 (API 32) and below and Android 13 (API 33) and above. * Updates Android documentation on how to use `permission.photo` on Android 12 (API 32) and below and Android 13 (API 33) and above.
......
...@@ -2,8 +2,8 @@ part of permission_handler_platform_interface; ...@@ -2,8 +2,8 @@ part of permission_handler_platform_interface;
/// Defines the state of a [Permission]. /// Defines the state of a [Permission].
enum PermissionStatus { enum PermissionStatus {
/// The user denied access to the requested feature, /// The user denied access to the requested feature, permission needs to be
/// permission needs to be asked first. /// asked first.
denied, denied,
/// The user granted access to the requested feature. /// The user granted access to the requested feature.
...@@ -12,19 +12,31 @@ enum PermissionStatus { ...@@ -12,19 +12,31 @@ enum PermissionStatus {
/// The OS denied access to the requested feature. The user cannot change /// The OS denied access to the requested feature. The user cannot change
/// this app's status, possibly due to active restrictions such as parental /// this app's status, possibly due to active restrictions such as parental
/// controls being in place. /// controls being in place.
///
/// *Only supported on iOS.* /// *Only supported on iOS.*
restricted, restricted,
///User has authorized this application for limited access. /// The user has authorized this application for limited access. So far this
/// is only relevant for the Photo Library picker.
///
/// *Only supported on iOS (iOS14+).* /// *Only supported on iOS (iOS14+).*
limited, limited,
/// Permission to the requested feature is permanently denied, the permission /// Permission to the requested feature is permanently denied, the permission
/// dialog will not be shown when requesting this permission. The user may /// dialog will not be shown when requesting this permission. The user may
/// still change the permission status in the settings. /// still change the permission status in the settings.
///
/// *On Android:*
/// Android 11+ (API 30+): whether the user denied the permission for a second
/// time.
/// Below Android 11 (API 30): whether the user denied access to the requested
/// feature and selected to never again show a request.
///
/// *On iOS:*
/// If the user has denied access to the requested feature.
permanentlyDenied, permanentlyDenied,
/// The application is provisionally authorized to post noninterruptive user /// The application is provisionally authorized to post non-interruptive user
/// notifications. /// notifications.
/// ///
/// *Only supported on iOS (iOS12+).* /// *Only supported on iOS (iOS12+).*
...@@ -68,8 +80,7 @@ extension PermissionStatusValue on PermissionStatus { ...@@ -68,8 +80,7 @@ extension PermissionStatusValue on PermissionStatus {
/// Utility getter extensions for the [PermissionStatus] type. /// Utility getter extensions for the [PermissionStatus] type.
extension PermissionStatusGetters on PermissionStatus { extension PermissionStatusGetters on PermissionStatus {
/// If the user denied access to the requested feature, /// If the user denied access to the requested feature.
/// permission needs to be asked first.
bool get isDenied => this == PermissionStatus.denied; bool get isDenied => this == PermissionStatus.denied;
/// If the user granted access to the requested feature. /// If the user granted access to the requested feature.
...@@ -78,9 +89,14 @@ extension PermissionStatusGetters on PermissionStatus { ...@@ -78,9 +89,14 @@ extension PermissionStatusGetters on PermissionStatus {
/// If the OS denied access to the requested feature. The user cannot change /// If the OS denied access to the requested feature. The user cannot change
/// this app's status, possibly due to active restrictions such as parental /// this app's status, possibly due to active restrictions such as parental
/// controls being in place. /// controls being in place.
///
/// *Only supported on iOS.* /// *Only supported on iOS.*
bool get isRestricted => this == PermissionStatus.restricted; bool get isRestricted => this == PermissionStatus.restricted;
/// If the permission to the requested feature is permanently denied, the
/// permission dialog will not be shown when requesting this permission. The
/// user may still change the permission status in the settings.
///
/// *On Android:* /// *On Android:*
/// Android 11+ (API 30+): whether the user denied the permission for a second /// Android 11+ (API 30+): whether the user denied the permission for a second
/// time. /// time.
...@@ -90,17 +106,18 @@ extension PermissionStatusGetters on PermissionStatus { ...@@ -90,17 +106,18 @@ extension PermissionStatusGetters on PermissionStatus {
/// ///
/// *On iOS:* /// *On iOS:*
/// If the user has denied access to the requested feature. /// If the user has denied access to the requested feature.
/// The user may still change the permission status in the settings
///
/// WARNING: This can only be determined AFTER requesting this permission.
/// Therefore make a `request` call first.
bool get isPermanentlyDenied => this == PermissionStatus.permanentlyDenied; bool get isPermanentlyDenied => this == PermissionStatus.permanentlyDenied;
/// Indicates that permission for limited use of the resource is granted. /// If the user has authorized this application for limited access. So far
/// this is only relevant for the Photo Library picker.
///
/// *Only supported on iOS (iOS14+).*
bool get isLimited => this == PermissionStatus.limited; bool get isLimited => this == PermissionStatus.limited;
/// If the application is provisionally authorized to post noninterruptive /// If the application is provisionally authorized to post non-interruptive
/// user notifications. /// user notifications.
///
/// *Only supported on iOS (iOS12+).*
bool get isProvisional => this == PermissionStatus.provisional; bool get isProvisional => this == PermissionStatus.provisional;
} }
...@@ -119,25 +136,30 @@ extension FuturePermissionStatusGetters on Future<PermissionStatus> { ...@@ -119,25 +136,30 @@ extension FuturePermissionStatusGetters on Future<PermissionStatus> {
/// *Only supported on iOS.* /// *Only supported on iOS.*
Future<bool> get isRestricted async => (await this).isRestricted; Future<bool> get isRestricted async => (await this).isRestricted;
/// If the permission to the requested feature is permanently denied, the
/// permission dialog will not be shown when requesting this permission. The
/// user may still change the permission status in the settings.
///
/// *On Android:* /// *On Android:*
/// Android 11+ (API 30+): whether the user denied the permission for a second /// Android 11+ (API 30+): whether the user denied the permission for a second
/// time. /// time.
/// Below Android 11 (API 30): whether the user denied access to the requested /// Below Android 11 (API 30): whether the user denied access to the requested
/// feature and selected to never again show a request. /// feature and selected to never again show a request.
/// The user may still change the permission status in the settings.
/// ///
/// *On iOS:* /// *On iOS:*
/// If the user has denied access to the requested feature. /// If the user has denied access to the requested feature.
/// The user may still change the permission status in the settings
Future<bool> get isPermanentlyDenied async => Future<bool> get isPermanentlyDenied async =>
(await this).isPermanentlyDenied; (await this).isPermanentlyDenied;
/// Indicates that permission for limited use of the resource is granted. /// If the user has authorized this application for limited access. So far
/// this is only relevant for the Photo Library picker.
///
/// *Only supported on iOS (iOS14+).*
Future<bool> get isLimited async => (await this).isLimited; Future<bool> get isLimited async => (await this).isLimited;
/// If the application is provisionally authorized to post noninterruptive /// If the application is provisionally authorized to post non-interruptive
/// user notifications. /// user notifications.
/// ///
/// *Only supported on iOS.* /// *Only supported on iOS (iOS12+).*
Future<bool> get isProvisional async => (await this).isProvisional; Future<bool> get isProvisional async => (await this).isProvisional;
} }
...@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin. ...@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a # NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 4.0.1 version: 4.0.2
dependencies: dependencies:
flutter: flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment