Baseflow / Baseflow/flutter-permission-handler

[Feature request]: Hide platform version details for Permission.photos

Open
#1,149 2 comments 3 reactions 0 assignees View on GitHub
P2 platform: android refactor type: enhancement
Dominant language
Dart
Stars
2.2k
Forks
970
Avg merge
14h 22m
Merged PRs (30d)
2

Description

### Is there already an issue requesting this feature?

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-permission-handler/issues).

### Please select affected platform(s)

- [X] Android
- [X] iOS
- [X] Windows

### Use case

When using permission_handler to check for photos permission you must check the platform and the Android version like so:

```dart
if (Platform.isAndroid) {
final androidInfo = await DeviceInfoPlugin().androidInfo;
if (androidInfo.version.sdkInt <= 32) {
/// use [Permission.storage]
} else {
/// use [Permission.photos]
}
}
```

This is explained in the documentation for `Permission.photos` [here](https://github.com/Baseflow/flutter-permission-handler/blob/11055f416ebc46cee9c33ab79b73e98721242b3b/permission_handler_platform_interface/lib/src/permissions.dart#L103). This runs against the design goal of Flutter plugins to hide platform-specific details whenever possible.

### Proposal

I propose that `Permission.photos` should be changed to do the platform and Android version checks itself so that it behaves as expected on lower Android versions.

This would be a breaking change, but it would serve to fix [this issue](https://github.com/Baseflow/flutter-permission-handler/issues/944) and seems worth it since most users of this plugin are in the future.

### Specific requirements or considerations

_No response_

### Additional information or context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.