requestPermission method
Implementation
@override
Future<PermissionStatus> requestPermission() async {
switch (repository.status ?? PermissionStatus.granted) {
case PermissionStatus.granted:
case PermissionStatus.limited:
// close permission page and back to the screen to request permission.
break;
case PermissionStatus.denied:
// if the permission is mandatory to use app, keep permission page.
await repository.request();
if (repository.status == PermissionStatus.limited ||
repository.status == PermissionStatus.granted) {
update(state: PermissionViewState.grantedAndExit);
}
break;
case PermissionStatus.permanentlyDenied:
// goto settings
bool ret = await openAppSettings();
if (ret) {
await repository.readPermissionStatus();
}
break;
case PermissionStatus.restricted:
// impossible to access
break;
}
_handleStatus(repository.status);
return repository.status ?? PermissionStatus.granted;
}