Created
March 3, 2020 06:59
-
-
Save bharathraj-e/4331a8c5c0a6d0a9cbcaa4d5ee2e3fe2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:permission_handler/permission_handler.dart'; | |
() async { | |
PermissionStatus p = await PermissionHandler() | |
.checkPermissionStatus(PermissionGroup.contacts); | |
if (p == PermissionStatus.disabled) { | |
// permission got already / success | |
return true; | |
} | |
Map<PermissionGroup, PermissionStatus> ps = | |
await PermissionHandler() | |
.requestPermissions([PermissionGroup.contacts]); | |
PermissionStatus q = ps[PermissionGroup.contacts]; | |
if (q == PermissionStatus.granted) { | |
// permission granted | |
// do the stuff | |
return true; | |
} | |
if (q == PermissionStatus.denied) { | |
// permission denied | |
// don't do the stuff | |
return false; | |
} | |
if (q == PermissionStatus.neverAskAgain) { | |
// user restricted the permission | |
return false; | |
// below code to open current app settings if u wish ... | |
// await PermissionHandler().openAppSettings(); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment