Last updated:
0 purchases
rx permissions
This package provides a reactive cross-platform (iOS, Android) API
to request and check permissions for the permission_handler package.
How to use #
Request a subject for the permission you are interested in.
List<Permission> requiredPermission = [Permission.camera, Permission.microphone];
final subject = rx_permissions.permissions(requiredPermission);
copied to clipboard
Once you have received the stream, you can observe it as usual and react to changes.
subject.listen((permissionResults) => onPermissionUpdate(permissionResults));
//...
void onPermissionUpdate(List<Permission> result) async {
List<PermissionResult> permissionResults = await Future.wait(result.map((i) async {
final granted = await i.isGranted;
final revoked = await i.isPermanentlyDenied;
return PermissionResult(i, granted, revoked);
}));
}
class PermissionResult {
final Permission permission;
final bool granted;
final bool revoked;
PermissionResult(this.permission, this.granted, this.revoked);
}
copied to clipboard
Call the request()-method to request the required permissions
rx_permissions.request(requiredPermission);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.