Flutter plugin for permissions handling on iOS and Android.
- get statuses of permissions
- request single/multiple permissions
- request notification permissions on iOS
- handle permissions on iOS
- handle permissions on Android
- iOS
- Android
TODO: List prerequisites and provide or point to information on how to start using the package.
enum Permissions
contains all declared permissions.
To request a single permission call:
final requestCameraStatus = await Permissions.camera.request();
if (requestCameraStatus == Status.authorized) { /* Do something */ }
Requesting multiple permissions:
final eventStatuses = await [
Permissions.calendar,
Permissions.reminderIOS,
].request();
for (var k in statuses.keys) {
debugPrint('Request event permission status - $k, status: ${eventStatuses[k]}');
}
Check status of a single permission:
final cameraStatus = await Permissions.camera.checkStatus();
if (cameraStatus == Status.authorized) { /* Do something */ }
Check status of multiple permissions:
final statuses = await [
Permissions.microphone,
Permissions.contacts,
Permissions.notification
].checkStatuses();
for (var k in statuses.keys) {
debugPrint('Permission - $k, status: ${statuses[k]}');
}
Check availability of permission on a phone capability example:
final checkPhone = await Permissions.phone.checkAvailability();
You can request notification permission with any option: alert, badge, sound, carPlay, criticalAlert, provisional, announcement, timeSensitive
final requestNotificationWithOptions =
await Permissions.notificationOptions.requestWithOptions([
PermissionOption.notificationOptionAlert,
PermissionOption.notificationOptionBadge,
PermissionOption.notificationOptionSound,
PermissionOption.notificationOptionCriticalAlert,
]);
debugPrint(
'Notification with options request permission status: $requestNotificationWithOptions');