How to detect permission dialog is denied by user

Viewed 266

I am implementing take pictures from galley in my app, for which I am adding storage permission. And I am requesting the permission from user using permission_handler package. And it is working perfectly in Android because it manages user state like permanently denied etc. But the main issue in the iOS in which either user deny or allow always shows user granted permission(Means always providing the status == granted)

Please help if someone have same issue or I am doing anything wrong.

Thank you.

1 Answers

Add permission_handler: ^6.1.1 to you pubspec file

import it

import 'package:permission_handler/permission_handler.dart';

in you landing page or main.dart try calling this bellow functoin

bool storagePer = false;
    void storageCheck() async {
      var status = await Permission.storage.status;
      if (!status.isGranted) {
        await Permission.storage.request();
        storagePer = true;
        print('per: $storagePer');
      }
    }

To check if you have permission or not, use status.isGranted if it return true => permissionGranted else denied

to request permition use this await Permission.storage.request();

Related