PermissionManager class

Constructors

PermissionManager()
factory

Properties

autoRefreshPeriodically bool
Whether the manager automatically refreshes its permission cache on a periodic timer (every periodicRefreshMinutes) in addition to refreshing on app resume. Defaults to true.
getter/setter pair
cacheTTLSeconds int
How long (in seconds) a cached permission status is considered fresh before checkPermissionsStatus re-queries the platform. Defaults to 3 seconds. Set this to tune the tradeoff between platform-channel call volume and status staleness for your app — e.g. a lower value if your UI needs to reflect Settings changes almost immediately, or a higher value if you're checking many permissions frequently and want to reduce platform-channel traffic.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
no setter
isInitialized bool
no setter
onAppResumed Stream<void>
no setter
onPermissionChanged Stream<PermissionChangeEvent>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkGroupPermissionsStatus(List<PermissionGroup> groups) Future<Map<PermissionGroup, bool>>
checkPermissionsStatus(List<PermissionType> permissions, {bool bypassCache = false}) Future<Map<PermissionType, PermissionResult>>
clearAllCache() → void
clearCache(PermissionType permission) → void
dispose() → void
getCurrentContext() BuildContext?
isPermissionGranted(PermissionType permission) Future<bool>
isPermissionPermanentlyDenied(PermissionType permission) Future<bool>
markInitialized() → void
Mark manager as initialized (call after WidgetsFlutterBinding.ensureInitialized())
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAppLifecycleStateChanged(AppLifecycleState state) → void
openAppSettings() Future<void>
openSettingsAndWaitForResume({Duration longWaitWarningAfter = const Duration(seconds: 30), void onLongWait()?}) Future<void>
The single, correct, race-free way to open Settings and wait for the user to actually return. Subscribes to onAppResumed before launching Settings — not after — so even an unrealistically fast resume cannot be missed. Every settings-redirect path in this package uses this method; nothing calls openAppSettings() followed by a separate wait anymore.
registerNavigatorKey(GlobalKey<NavigatorState> key) → void
requestPermission(PermissionType permission, {BuildContext? context, bool useSmartRationale = false}) Future<PermissionResult>
requestPermissionGroup(PermissionGroup group, {BuildContext? context}) Future<Map<PermissionType, PermissionResult>>
requestPermissions(List<PermissionType> permissions, {BuildContext? context, bool showExplanation = true, bool showDeniedDialog = true}) Future<Map<PermissionType, PermissionResult>>
requestPermissionWithExplanation(PermissionType permission, {BuildContext? context, bool showExplanation = true, bool showDeniedDialog = true, bool useSmartRationale = false}) Future<PermissionResult>
setCurrentContext(BuildContext context) → void
setGroupExplanationCallback(PermissionGroup group, PermissionGroupExplanationCallback? callback) → void
Register a custom explanation UI for a whole group, replacing the built-in dialog for every permission requested as part of that group. Pass null to remove a previously-registered callback and fall back to the default.
setPermissionExplanationCallback(PermissionType permission, PermissionExplanationCallback? callback) → void
Register a custom explanation UI for a single permission, replacing the built-in dialog. Pass null to remove a previously-registered callback and fall back to the default.
shouldShowRationale(PermissionType permission) Future<bool>
Whether the OS recommends showing a rationale before re-requesting this permission — i.e. the user denied it once (but not permanently) and a plain re-request without explanation is likely to be denied again. Android-only: permission_handler always returns false on iOS, since iOS has no equivalent signal.
toString() String
A string representation of this object.
inherited
unregisterNavigatorKey(GlobalKey<NavigatorState> key) → void
waitForNextResume({Duration longWaitWarningAfter = const Duration(seconds: 30), void onLongWait()?}) Future<void>
Waits for the app to actually resume (a real return-to-app lifecycle transition — see onAppResumed) rather than guessing with a fixed delay.

Operators

operator ==(Object other) bool
The equality operator.
inherited