Baseflow / flutter-permission-plugins

This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.
https://baseflow.com
MIT License
52 stars 33 forks source link

Multiple bugs when we deny location permission and then ask for it again #38

Open tomasbaran opened 4 years ago

tomasbaran commented 4 years ago

🐛 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: IMG_13BCC33E7FB4-1

Reproduction steps

For reproduction, please see this repo: https://github.com/tomasbaran/location_permissions

Bug A

  1. Tap Don't Allow
  2. Tap Enable Location
  3. Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
  4. Go back to the app
  5. Tap Don't Allow
  6. Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
  7. 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

  1. Tap Don't Allow
  2. Tap Enable Location
  3. Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
  4. Wait 10 seconds (if you don't wait for 10 seconds and you do it right away, everything works as it should)
  5. Go back to the app
  6. 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

  1. Tap Don't Allow
  2. Tap Enable Location
  3. Set Allow Always (but iOS doesn't refresh the status, so please go back one step and then do it)
  4. Go back to the app
  5. Throws a '!debugLocked is not true' error

Configuration

Version: 2.0.5

Platform:

milhomem commented 4 years ago

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