flutter-permission-plugins
flutter-permission-plugins copied to clipboard
Multiple bugs when we deny location permission and then ask for it again
🐛 Bug Report
These are minor bugs but I wanted to report them anyway. There are actually 3 different bugs but I believe they are related so I'm reporting them as one.
Expected behavior
Bug A
there shouldn't be ERROR_ALREADY_REQUESTING_PERMISSION
Bug B
Request permission pop up shouldn't get stuck and should pop up right away.
Bug C
There should NOT be this error:

Reproduction steps
For reproduction, please see this repo: https://github.com/tomasbaran/location_permissions
Bug A
- Tap Don't Allow
- Tap Enable Location
- Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
- Go back to the app
- Tap Don't Allow
- Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
- Now it throws an error which I don't believe makes sense since there was no requested permission running: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSION, A request for permissions is already running, please wait for it to finish before doing another request., null)
Bug B
- Tap Don't Allow
- Tap Enable Location
- Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
- Wait 10 seconds (if you don't wait for 10 seconds and you do it right away, everything works as it should)
- Go back to the app
- The Requested Permission Pop up got stuck: doesn't throw any error but doesn't pop up the Permission request.
This issue always happens on Simulator and sometimes happens on real iPhone sometimes not
Bug C
- Tap Don't Allow
- Tap Enable Location
- Set Allow Always (but iOS doesn't refresh the status, so please go back one step and then do it)
- Go back to the app
- Throws a '!debugLocked is not true' error
Configuration
Version: 2.0.5
Platform:
- [x] :iphone: iOS
- [ ] :robot: Android
@tomasbaran I checked your repo and I believe that at least for Bug C your problem is that you are calling the method on initState() and that's not correct because the widget will not be mounted.
This will end up calling the method multiple times.
Please see https://www.didierboelens.com/2019/04/addpostframecallback/ for detailed information.