Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
ChristianEdwardPadilla opened this issue Sep 10, 2023 · 2 comments
Open
4 tasks done
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. refactor Issues marked with refactor should be considered when refactoring the plugin. type: enhancement New feature or request

Comments

@ChristianEdwardPadilla
Copy link
Contributor

Is there already an issue requesting this feature?

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Use case

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

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. 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 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

@JeroenWeener JeroenWeener added platform: android Issue is related to the Android platform. type: enhancement New feature or request P2 Important issues not at the top of the work list. labels Sep 12, 2023
@TimHoogstrate TimHoogstrate self-assigned this Oct 18, 2023
@ChristianEdwardPadilla
Copy link
Contributor Author

FYI in the meantime we are considering adding an extension something like this:

extension PermissionExtension on Permission {
  static Future<Permission> get photosOrStorage async {
    final androidInfo = await DeviceInfoPlugin().androidInfo;
    final isAndroidTPlus = (androidInfo.version.sdkInt ?? 0) >= 33;
    if (isAndroidTPlus) {
      return Permission.photos;
    } else {
      return Permission.storage;
    }
  }
}

But it would be better to come from permission_handler itself, IMO. The cross-plugin dependency on device_info_plus is not ideal here.

@JeroenWeener JeroenWeener added the refactor Issues marked with refactor should be considered when refactoring the plugin. label Oct 19, 2023
@TimHoogstrate
Copy link
Contributor

Dear @ChristianEdwardPadilla,

Thanks for submitting this feature. We discussed this feature request in the team and we decided to label this issue as an enhancement. We are working on a refactor of the permission handler. During the refactor we well be handling this feature request.

Kind regards,

@TimHoogstrate TimHoogstrate removed their assignment Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. refactor Issues marked with refactor should be considered when refactoring the plugin. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants