PermissionHandler class
A singleton class that manages and checks various permissions required by the application.
The PermissionHandler provides methods to check and request permissions such as camera, microphone, bluetooth, storage, contacts, location, notification, biometric, calendar, and sensors. It maintains the current state of each permission and exposes getters to check if a specific permission is granted.
Usage:
- Use PermissionHandler.instance to access the singleton instance.
- Call init with a list of permission types to initialize and check their statuses.
- Use the provided getters (e.g., isCameraPermissionGranted) to check permission states.
- Use requestPermission to request a specific permission at runtime.
Example:
PermissionHandler.instance.init([Permission.camera, Permission.microphone]);
bool isCameraGranted = PermissionHandler.instance.isCameraPermissionGranted;
await PermissionHandler.instance.requestPermission(Permission.camera);
Note: The permission types should match the constants defined in the Permission class.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isBiometricPermissionGranted → bool
-
Returns
trueif biometric permission is granted.no setter - isBluetoothPermissionGranted → bool
-
Returns
trueif bluetooth permission is granted.no setter - isCalendarPermissionGranted → bool
-
Returns
trueif calendar permission is granted.no setter - isCameraPermissionGranted → bool
-
Returns
trueif camera permission is granted.no setter - isContactsPermissionGranted → bool
-
Returns
trueif contacts permission is granted.no setter - isLocationPermissionGranted → bool
-
Returns
trueif location permission is granted.no setter - isMicrophonePermissionGranted → bool
-
Returns
trueif microphone permission is granted.no setter - isNotificationPermissionGranted → bool
-
Returns
trueif notification permission is granted.no setter - isSensorsPermissionGranted → bool
-
Returns
trueif sensors permission is granted.no setter - isStoragePermissionGranted → bool
-
Returns
trueif storage permission is granted.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkPermission(
String type) → Future< bool> - Checks if the specified permission type is granted.
-
init(
List< String> checkPermissionList) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openSettings(
) → Future< void> -
requestPermission(
String type) → Future< bool> - Requests the specified permission type from the user.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → PermissionHandler
-
final