-
-
Notifications
You must be signed in to change notification settings - Fork 895
[Bug]: Callbacks like onGrantedCallback does not work as expected. #1414
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
Comments
Dear @ebsangam, Can you elaborate a bit on the subject? Are you testing this in iOS or Android? And what version of OS? Kind regards, |
I was testing on Android emulator SDK 34. I wanted to listen to contacts permission status change (on granted to be specific). So I used |
Running into the same issue. (Only tried building on Android so far, but I imagine all the platforms have this error.) Here's a full flutter app code to replicate it:
Of course, you'll need to add the requisite permissions to Android manifest as well, and add permission_handler to pubspec.yaml as well:
|
Here's a recording of the odd behavior: error-recording.mp4(Same code as I posted above.) |
As for my Android version, it's Android 13 (build 6.A.031.7). |
Requesting the permission works fine (also in the example app), you can check it in the app settings after requesting and approving the permissions. However, your demo app is just presenting the results wrongly. Try to keep the registration of the callbacks outside of the build method. @ebsangam I've verified that is works properly in the example app. Kind regards, |
I think you misunderstood the issue. Let's not focus on the example app instead my original issue I mentioned. It is the issue about callback that fires unnecessarily. |
Dear @ebsangam, Still I cannot reproduce this. Please provide me with a clear sample. Again, I tested this but I cannot reproduce this. The sample of @12people is just not working properly. If I change any of the permissions from Permission.notification to another (for example contacts I get the same results (only then with .contacts). Kind regards, |
I will provide you a minimal reproducible code when I am free. |
You're right, setting callbacks in the However, if I set the callbacks once in the
Let me know if I'm doing anything wrong here (and if I am, why it's wrong and how to do it right). Also, you mention the example app, but the example app in |
Here's a recording of the new code: Screen.Recording.2025-03-18.at.11.07.51.movNotice how the notification-related callbacks are run when the location permission is set, rather than the location-related callbacks that should be run. |
Uh oh!
There was an error while loading. Please reload this page.
Please check the following before submitting a new issue.
Please select affected platform(s)
Steps to reproduce
Permission.contacts.onGrantedCallback
Permission.contacts.onGrantedCallback
will be invoked.Expected results
When using
Permission.contacts.onGrantedCallback
we expect this callback to invoke only if we grant permission for contacts.Actual results
No mater what permission you add callback it will always gets invoked for every permission.
Code sample
Code sample
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
11.0.1
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: