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

[Question]: isGranted getter method conflict #1320

Closed
4 of 5 tasks
ksyeoh opened this issue May 16, 2024 · 2 comments
Closed
4 of 5 tasks

[Question]: isGranted getter method conflict #1320

ksyeoh opened this issue May 16, 2024 · 2 comments
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. platform: ios Issue is related to the iOS platform status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. status: needs more info We need more information before we can continue work on this issue.

Comments

@ksyeoh
Copy link

ksyeoh commented May 16, 2024

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • Android
  • iOS
  • Windows

Your question

I suddenly encountered an issue on parts of my code calling isGranted. The only change I remember prior to getting this error is upgrading my Android Studio. Currently, I'm able to build if I remove the caret in the pubspec.yaml from permission_handler: ^11.0.1 to permission_handler: 11.0.1. If I use ^11.0.1, it will point to permission_handler-11.3.1\lib\permission_handler.dart and the error below will appear. Can anyone advice please? Btw, I tried open the same flutter project on another Windows device and it doesn't have this issue.

A member named 'isGranted' is defined in extension 'PermissionCheckShortcuts' and extension 'PermissionStatusGetters', and none are more specific.
Try using an extension override to specify the extension you want to be chosen.

This is how I import and part of the affected code:-

import 'package:permission_handler/permission_handler.dart' as permission;
...
await permission.Permission.locationWhenInUse.isGranted;

image

Version

^11.0.1

@mvanbeusekom
Copy link
Member

Hi @ksyeoh,

Thank you for submitting this issue. Unfortunately I cannot reproduce the error and we have not done any recent upgrades ourselves. Version 11.3.1 was released 49 days ago.

The PermissionStatusGetters and PermissionCheckShortcuts have been added to the code base 4 years ago and are both extensions on different enums. The PermissionStatusGetters are an extension on the PermissionStatus enum, while the PermissionCheckShortcuts extend the Permission enum:

See definitions here:

Possibly Android Studio is confused some how, could you try the following:

  1. Remove all the permission_handler related packages from the local cache.
  2. Run flutter clean in the root of your project.
  3. Invalidates caches in Android Studio:
  • Open Android Studio
  • Select "File" from the top menu
  • Select "Invalidate caches..."

As mentioned I have tried to reproduce the error using the "Example" application with my copy of Android Studio and experienced no problem. The application compiled and ran without any problems on my Android Pixel 7a device. Here are some details on my environment:

Android Studio Iguana | 2023.2.1
Build #AI-232.10227.8.2321.11479570, built on February 21, 2024
Runtime version: 17.0.9+0-17.0.9b1087.7-11185874 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.4.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 10
Metal Rendering is ON
Registry:
    ide.experimental.ui=true

Non-Bundled Plugins:
    Dart (232.10313)
    google-java-format (1.22.0.0)
    io.flutter (79.0.1)

Output of flutter doctor -v command:

[✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
    • Flutter version 3.22.0 on channel stable at /Users/maurits/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (7 days ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/maurits/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (5 available)
    • Pixel 7a (mobile)                      • 31071JEHN18081            • android-arm64  • Android 14 (API 34)
    • Maurits van Beusekom’s iPhone (mobile) • 00008101-000D543E1A40001E • ios            • iOS 17.4.1 21E236
    • macOS (desktop)                        • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Mac Designed for iPad (desktop)        • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                           • chrome                    • web-javascript • Google Chrome 125.0.6422.60

[✓] Network resources
    • All expected network resources are available.

• No issues found!

@mvanbeusekom mvanbeusekom added platform: android Issue is related to the Android platform. platform: ios Issue is related to the iOS platform status: needs more info We need more information before we can continue work on this issue. P2 Important issues not at the top of the work list. labels May 17, 2024
Copy link

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

@github-actions github-actions bot added the status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. label May 31, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2024
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. platform: ios Issue is related to the iOS platform status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. status: needs more info We need more information before we can continue work on this issue.
Projects
None yet
Development

No branches or pull requests

2 participants