Baseflow / flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
https://baseflow.com
MIT License
2.05k stars 857 forks source link

[Reply already submitted] java.lang.IllegalStateException: Reply already submitted #539

Closed mayur1433 closed 1 year ago

mayur1433 commented 3 years ago

After the add, this Permission manage external storage I got the below error any can help me? Screenshot 2021-04-29 at 5 07 17 PM

[ ] E/AndroidRuntime( 9539): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=210, result=0, data=null} to activity {com.rbeat/io.flutter.embedding.android.FlutterActivity}: java.lang.IllegalStateException: Reply already submitted [ ] E/AndroidRuntime( 9539): at android.app.ActivityThread.deliverResults(ActivityThread.java:5213) [ ] E/AndroidRuntime( 9539): at android.app.ActivityThread.handleSendResult(ActivityThread.java:5254) [ ] E/AndroidRuntime( 9539): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) [ ] E/AndroidRuntime( 9539): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) [ ] E/AndroidRuntime( 9539): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) [ ] E/AndroidRuntime( 9539): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2246) [ ] E/AndroidRuntime( 9539): at android.os.Handler.dispatchMessage(Handler.java:106) [ ] E/AndroidRuntime( 9539): at android.os.Looper.loop(Looper.java:233) [ ] E/AndroidRuntime( 9539): at android.app.ActivityThread.main(ActivityThread.java:8010) [ ] E/AndroidRuntime( 9539): at java.lang.reflect.Method.invoke(Native Method) [ ] E/AndroidRuntime( 9539): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) [ ] E/AndroidRuntime( 9539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) [ ] E/AndroidRuntime( 9539): Caused by: java.lang.IllegalStateException: Reply already submitted [ ] E/AndroidRuntime( 9539): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155) [ ] E/AndroidRuntime( 9539): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238) [ ] E/AndroidRuntime( 9539): at com.baseflow.permissionhandler.-$$Lambda$fOfJ7OpNBkhP48Mtzqs01exhUJs.onSuccess(Unknown Source:2) [ ] E/AndroidRuntime( 9539): at com.baseflow.permissionhandler.PermissionManager.onActivityResult(PermissionManager.java:64) [ ] E/AndroidRuntime( 9539): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistr y.java:739) [ ] E/AndroidRuntime( 9539): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:426) [ ] E/AndroidRuntime( 9539): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:677) [ ] E/AndroidRuntime( 9539): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:616) [ ] E/AndroidRuntime( 9539): at android.app.Activity.dispatchActivityResult(Activity.java:8316) [ ] E/AndroidRuntime( 9539): at android.app.ActivityThread.deliverResults(ActivityThread.java:5206) [ ] E/AndroidRuntime( 9539): ... 11 more [ +27 ms] I/Process ( 9539): Sending signal. PID: 9539 SIG: 9

mvanbeusekom commented 3 years ago

@mayur1433 it would be great if you could provide some additional information:

  1. Could you list the other plugins/ dependencies that you are using in your app? This seems closely related to an earlier issue we experienced, where two plugins use the same requestCode when starting an intent and both would then try to handle the result, resulting in multiple calls to the result object;
  2. The output of the flutter doctor -v command;
  3. The version of the permission_handler plugin you are using.
mayur1433 commented 3 years ago

@mvanbeusekom please help me, sir.

  1. Could you list the other plugins/ dependencies that you are using in your app? This seems closely related to an earlier issue we experienced, where two plugins use the same requestCode when starting an intent and both would then try to handle the result, resulting in multiple calls to the result object;

ANS: Yes

  1. The output of the flutter doctor -v command;

[✓] Flutter (Channel stable, 2.0.5, on macOS 11.2.2 20D80 darwin-x64, locale en-GB) • Flutter version 2.0.5 at /Volumes/DATA/Sdk/flutter • Framework revision adc687823a (2 weeks ago), 2021-04-16 09:40:20 -0700 • Engine revision b09f014e96 • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/mayur/Library/Android/Sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = /Users/mayur/Library/Android/Sdk • ANDROID_SDK_ROOT = /Users/mayur/Library/Android/Sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.4, Build version 12D4e • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.1) • 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 1.8.0_242-release-1644-b3-6915495)

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

  1. The version of the permission_handler plugin you are using.

ANS: permission_handler: ^7.0.0

environment: sdk: ">=2.7.0 <3.0.0"

dependencies: flutter: sdk: flutter cached_network_image: ^2.5.1 connectivity: ^3.0.2 cupertino_icons: ^1.0.2 flutter_staggered_grid_view: ^0.3.4 flutter_svg: ^0.21.0-nullsafety.0 http: ^0.13.0 lottie: ^1.0.1 mvc_pattern: ^7.0.1 path_provider: ^2.0.1 pull_to_refresh: ^1.6.3 chewie: ^1.0.0 video_player: ^2.1.0 rxdart: ^0.25.0 dio: ^4.0.0 archive: ^3.1.2 flutter_ffmpeg: ^0.4.0 image_picker: ^0.7.4 image_cropper: ^1.4.0 package_info: ^2.0.0 fluttertoast: ^8.0.3 url_launcher: ^6.0.3 device_info: ^2.0.0 sqflite: ^2.0.0+3 video_thumbnail: ^0.3.3 share: ^2.0.1 shared_preferences: ^2.0.5 firebase_core: ^1.0.2 firebase_database: ^6.1.2 firebase_messaging: ^9.1.3 flutter_local_notifications: ^5.0.0+3 permission_handler: 7.0.0

dev_dependencies: flutter_test: sdk: flutter

dependency_overrides:

sn1cka commented 3 years ago

I have same issue. Im getting it when trying to request Permission.ignoreBatteryOptimizations in List.request();

Here's the code when im getting this exception.

var mList = [Permission.microphone, Permission.notification, Permission.storage, Permission.ignoreBatteryOptimizations]; mList.request();

Here is my pubspec.yaml:

`name: mega_recorder description: A new Flutter application.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment: sdk: ">=2.12.0 <3.0.0"

dependencies: flutter: sdk: flutter flutter_sound: ^8.1.4 permission_handler: ^8.1.1 hive: ^2.0.4 hive_flutter: ^1.0.0 equatable: ^2.0.3 bloc: ^7.0.0 flutter_bloc: ^7.0.1 path_provider: ^2.0.2 flutter_background: ^1.0.1 awesome_notifications: ^0.0.6+9 intl: ^0.17.0 move_to_background: ^1.0.2 auto_route: ^2.2.0 flutter_foreground_plugin: ^0.8.0 socket_io_client: ^1.0.1 json_annotation: ^4.0.1 dio: ^4.0.0

cupertino_icons: ^1.0.3

dev_dependencies: flutter_test: sdk: flutter auto_route_generator: ^2.1.0 json_serializable: ^4.1.3 build_runner: ^2.0.4 disk_space: ^0.1.1

flutter:

uses-material-design: true

`

EinatK commented 3 years ago

Same issue here, i see the crash in crashlytics, haven't reproduced it locally. I suspect it's either storage or camera permissions.

the error is Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=24, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.mobitti.hadassah/com.mobitti.mobitti_flutter_app.MainActivity}: java.lang.IllegalStateException: Reply already submitted

my other dependencies :

dependencies: async: ^2.5.0 barcode_scan2: ^4.1.4 cached_network_image: ^3.0.0 carousel_slider: ^2.3.1 connectivity_plus: ^2.0.2 device_calendar: ^3.1.0 device_info: ^2.0.0 f_logs: ^2.0.0 file_picker: ^3.0.3 firebase_analytics: ^8.2.0 firebase_auth: ^3.1.2 firebase_core: ^1.7.0 firebase_crashlytics: ^2.1.1 firebase_messaging: ^10.0.8 flip_card: ^0.5.0 flutter: sdk: flutter flutter_absolute_path: ^1.0.6 flutter_calendar_carousel: ^2.0.1 flutter_email_sender: ^5.0.2 flutter_fgbg: ^0.1.0 flutter_local_notifications: ^8.1.0 flutter_localizations: sdk: flutter flutter_microsoft_authentication: git: url: https://github.com/einatguri/flutter-microsoft-authentication.git ref: ca47774fff4dc4711682f4e1292366b660e6f101 flutter_svg: ^0.21.0-nullsafety.0 flutter_week_view: git: url: https://github.com/einatguri/FlutterWeekView.git ref: master flutter_zoom_drawer: ^2.1.1 fluttertoast: ^8.0.6 geolocator: ^7.7.1 get_it: ^5.0.3 google_fonts: ^2.0.0 google_maps_flutter: ^2.0.6 google_sign_in: ^5.1.1 html: ^0.15.0 http: ^0.13.1 image_picker: ^0.8.1+3 intl: ^0.17.0 local_auth: ^1.1.5 map_launcher: ^2.1.1 marquee: ^2.1.0 mobitti_webview: path: ../mobitti_webview network_info_plus: ^2.0.2 network_to_file_image: ^2.3.8 otp_text_field: ^1.1.1 package_info: ^0.4.3+2 path_provider: ^2.0.1 permission_handler: ^8.2.5 provider: ^6.0.1 rxdart: ^0.26.0 sembast: ^3.1.1 shared_preferences: ^2.0.5 sliding_up_panel: ^2.0.0+1 ssh: ^0.0.7 toggle_switch: ^1.2.0 transparent_image: ^1.0.0 uuid: ^3.0.4 webview_flutter: ^2.0.10 xml: ^5.0.2 xml2json: ^5.2.0

xiejinpeng007 commented 2 years ago

I have same issue , app crash in some devices report by Google Play, but I can't reproduce. The only thing I did is request the camera permission.


java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4510)
  at android.app.ActivityThread.handleSendResult (ActivityThread.java:4552)
  at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1912)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6858)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:883)
Caused by: java.lang.IllegalStateException: 
  at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply (DartMessenger.java:35)
  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success (MethodChannel.java:14)
  at com.baseflow.permissionhandler.-$$Lambda$fOfJ7OpNBkhP48Mtzqs01exhUJs.onSuccess (-.java:2)
  at com.baseflow.permissionhandler.PermissionManager.onRequestPermissionsResult (PermissionManager.java:241)
  at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onRequestPermissionsResult (FlutterEngineConnectionRegistry.java:20)
  at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult (FlutterEngineConnectionRegistry.java:15)
  at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onRequestPermissionsResult (FlutterActivityAndFragmentDelegate.java:59)
  at io.flutter.embedding.android.FlutterActivity.onRequestPermissionsResult (FlutterActivity.java:10)
  at android.app.Activity.dispatchRequestPermissionsResult (Activity.java:7660)
  at android.app.Activity.dispatchActivityResult (Activity.java:7510)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4503)
  at android.app.ActivityThread.handleSendResult (ActivityThread.java:4552)
  at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1912)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6858)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:883)

-----------------
environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.3

  # Internationalization
  flutter_localizations:
    sdk: flutter

  # GetX
  get: ^4.1.4

  # Http Client
  dio: 4.0.4
  dio_cookie_manager: 2.0.0

  # Data persistence
  sqflite: ^2.0.0+3
  shared_preferences: ^2.0.6

  # Tools
  url_launcher: ^6.0.7
  intl: ^0.17.0
  path: ^1.8.0
  path_provider: ^2.0.1
  dartz: ^0.10.0-nullsafety.2
  rxdart: ^0.27.0
  equatable: ^2.0.0
  permission_handler: 8.1.6
  device_info: ^2.0.0
  share_plus: ^2.1.2
  package_info_plus: ^1.0.3
  connectivity_plus: ^1.0.5
  ntp: ^2.0.0
#  android_intent_plus: ^1.0.2
  # Widget
  webview_flutter: ^2.0.4
  flutter_inappwebview: ^5.3.2
  fluttertoast: ^8.0.7
  retry: ^3.1.0

  firebase_core: ^1.7.0
  firebase_crashlytics: ^2.2.3
  firebase_remote_config: ^0.11.0
  adjust_sdk: ^4.29.1
  system_proxy:
    git: https://github.com/fenrir-cd/flutter_system_proxy.git

dev_dependencies:
  flutter_test:
    sdk: flutter
  mockito: 5.0.16
  build_runner: ^2.1.2
au-top commented 2 years ago

+1

i call code await ListenCall.requestPhonePermission

java.lang.IllegalStateException: Reply already submitted


[✓] Flutter (Channel master, 2.11.0-0.0.pre.537, on macOS 12.1 21C52 darwin-x64,
    locale en-CN)
    • Flutter version 2.11.0-0.0.pre.537 at /Users/autop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 0f33a369bf (9 days ago), 2022-02-13 00:20:20 -0500
    • Engine revision 80b7a8cd9a
    • Dart version 2.17.0 (build 2.17.0-104.0.dev)
    • DevTools version 2.10.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/autop/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

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

[✓] Android Studio (version 2020.3)
    • 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 11.0.10+0-b96-7281165)

[✓] IntelliJ IDEA Community Edition (version 2021.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

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

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.102


environment:
  sdk: ">=2.17.0-104.0.dev <3.0.0"
  flutter: ">=2.5.0"

dependencies:
  flutter:
    sdk: flutter
  permission_handler: ^9.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^1.0.0

``
EinatK commented 2 years ago

Any news on this ?

jeromeDms commented 2 years ago

Same issue. I'm using contacts and location permissions. Multiple crashes reported by firebase

luttmfra commented 2 years ago

Same issue. location permission.

sunqihui222 commented 2 years ago

Same issue. manageExternalStorage permission.

sanekyy commented 2 years ago

Hi @mvanbeusekom!

I faced with same error in our app. Catched by Firebase Crashlytics.

permission_handler version is 9.0.2 permission_handler_platform_interface version is 3.7.0

Errors only with ResultInfo.request 209 or 211.

Here is actual stack trace:

``` Fatal Exception: java.lang.RuntimeException Failure delivering result ResultInfo{who=null, request=209, result=0, data=null} to activity {xxx.xxx.xxx.MainActivity}: java.lang.IllegalStateException: Reply already submitted ``` ``` io.flutter.embedding.engine.dart.DartMessenger$Reply.reply (DartMessenger.java:430) io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success (MethodChannel.java:267) com.baseflow.permissionhandler.-$$Lambda$fOfJ7OpNBkhP48Mtzqs01exhUJs.onSuccess (-.java:2) com.baseflow.permissionhandler.PermissionManager.onActivityResult (PermissionManager.java:100) io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult (FlutterEngineConnectionRegistry.java:805) io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult (FlutterEngineConnectionRegistry.java:428) io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult (FlutterActivityAndFragmentDelegate.java:807) io.flutter.embedding.android.FlutterActivity.onActivityResult (FlutterActivity.java:724) android.app.Activity.dispatchActivityResult (Activity.java:8659) android.app.ActivityThread.deliverResults (ActivityThread.java:5939) android.app.ActivityThread.handleSendResult (ActivityThread.java:5985) android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:54) android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45) android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135) android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95) android.app.ActivityThread$H.handleMessage (ActivityThread.java:2443) android.os.Handler.dispatchMessage (Handler.java:106) android.os.Looper.loopOnce (Looper.java:226) android.os.Looper.loop (Looper.java:313) android.app.ActivityThread.main (ActivityThread.java:8751) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135) ```

I checked source code of plugin and there is ongoing flag to handle this errors. So I can't imagine how it is possible with this flag.

deckerst commented 1 year ago

I can't reproduce myself but I saw a crash report with:

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=24, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {deckers.thibault.aves/deckers.thibault.aves.MainActivity}: java.lang.IllegalStateException: Reply already submitted

Note ResultInfo.request is 24. Rest of the stack is the same as others above.

droplet-js commented 1 year ago

any news update?

sanekyy commented 1 year ago

Hi @mvanbeusekom!

This error still reproducing in production.

I added throttle to request permission button and this error reproducing with throttle too (3 seconds between clicks).

This error crash entire app, so can you please somehow help with resolving this error.

liu731 commented 1 year ago

+1 Unable to reproduce, request=24. Rest of the stack is the same as others above.

permission_handler: 9.2.0

huang1592847 commented 1 year ago

await [ Permission.storage, ].request(); await [ Permission.manageExternalStorage, ].request(); Request permissions separately, not together 申请权限分开请求,不要写在一起

Passer-by commented 1 year ago

Same issue.

Shik1266 commented 1 year ago

any news update?

TimHoogstrate commented 1 year ago

Is anyone able to reproduce this issue with clear steps? Other than the steps in this issue: https://github.com/Baseflow/flutter-permission-handler/issues/1126

JeroenWeener commented 1 year ago

Very likely a duplicate of #761. See also https://github.com/Baseflow/flutter-permission-handler/issues/761#issuecomment-1701144011