Home > other >  Flutter : Ask the user for permission until permission is granted
Flutter : Ask the user for permission until permission is granted

Time:02-26

Using https://pub.dev/packages/permission_handler to get permissions

but it won't ask the user again if user denied permission.

currently checked it on android (iOS device is not available)

Pls Help

CodePudding user response:

As i understood you want to continuously ask user for permission if it is denied. You can implement something like this to continuously ask for the request unless you get something other than denied :

 Future<bool> askPermission() async{
    PermissionStatus status = await Permission.contacts.request();
    if(status.isDenied == true)
      {
        askPermission();
      }
    else
      {
        return true;
      }
  }

Call this type of method wherever you are requesting for the permission.

CodePudding user response:

If a user has already denied, only thing could be done is to redirect the user to application settings to enable needed permissions.

if (await Permission.speech.isPermanentlyDenied) {
  // The user opted to never again see the permission request dialog for this
  // app. The only way to change the permission's status now is to let the
  // user manually enable it in the system settings.
  openAppSettings();
}
  • Related