Skip to content

Changes in 6.0.0

Maurits van Beusekom edited this page Mar 17, 2021 · 3 revisions

Stable release for null safety

As of version 6.0.0 the permission_handler has been updated for Flutter 2 and null safety.

Breaking changes

From version 6.0.0 the PermissionStatus.undetermined status has been removed. This choice has been made because of the way the Android API has been changed in API 30+. The introduction of the "Ask every time" resulted in a bug in the old implementation. For more a more in depth explanation, check the geolocator wiki.

The new implementation returns PermissionStatus.denied instead of PermissionStatus.undetermined when the app has not asked for the permission yet, or when the permission has expired (by the use of Ask every time).

In the old implementation permission_handler saved the status in Android's Shared Preferences to determine if the permission was permanently denied. The implementation now does not save this info, so this needs to be checked twice, to determine permanently denied permissions. Like so:

Permission permission = Permission.photos;
PermissionStatus permissionStatus = await permission.status;
if (permissionStatus == PermissionStatus.denied) {
  permissionStatus = await permission.request();
  if (permissionStatus == PermissionStatus.permanentlyDenied) {
    // Permission is denied forever, handle appropriately. 
    return;
  } 

  if (permissionStatus == PermissionStatus.denied) {
    // Permission is denied, next time you could try
    // requesting the permission again (this is also where
    // Android's shouldShowRequestPermissionRationale 
    // returned true. According to Android guidelines
    // your App should show an explanatory UI now.
    return;
  }
}

Release information

Clone this wiki locally