testing library

Test doubles for consumers of this package.

Import this in your own tests to drive the full permission flow without a device:

import 'package:baaba_permission_handler/testing.dart';

Nothing here is imported by the package's production code, so it adds no weight to your app.

Classes

BaabaPermissions
Checks and requests runtime permissions, and walks the user through everything that can go wrong along the way.
DefaultPermissionPlatform
The real implementation, backed by permission_handler, device_info_plus and app_settings.
DialogPolicy
Which follow-up dialogs the flow may show. The rationale is governed by RationaleMode instead.
FakePermissionPlatform
An in-memory OS for tests: drive the whole permission flow — dialogs included — in a widget test, with no device and no method channel.
ImmediateSettingsReturnWaiter
Completes straight after open — no lifecycle to wait on.
InMemoryPermissionStore
LifecycleSettingsReturnWaiter
Waits on the app lifecycle.
Permission
Defines the permissions which can be checked and requested.
PermissionConfig
App-wide settings for BaabaPermissions. Every field has a default, and PermissionRequestOptions can override most of them for a single call.
PermissionDialogData
Everything a dialog needs, with every string already resolved and every placeholder filled — a custom builder only has to lay it out.
PermissionDialogItem
One permission's row in a dialog.
PermissionDialogTheme
Look of the built-in dialogs, sheets and gate. Anything left null comes from the app's Theme, so the defaults already match the app.
PermissionGate
Shows child only once every permission is allowed, and keeps that true: it re-checks when the app returns to the foreground (the user may have changed it in Settings) and after any request through the same BaabaPermissions.
PermissionHistory
What the package remembers about asking for one permission.
PermissionObserver
One place to watch every permission decision — for analytics ("how many users deny the camera on the KYC screen?"), crash reporting, or logs.
PermissionPlan
How to obtain one AppPermission on one device: which native permissions to request, in what order, and which service has to be switched on.
PermissionPlatform
The seam between the permission flow and the OS.
PermissionPromptContent
The built-in dialog/sheet body. Public so a custom PermissionDialogWidgetBuilder can wrap or decorate it rather than rebuild it from scratch:
PermissionPromptCupertinoDialog
The built-in iOS-style alert, used on iOS when PermissionDialogTheme.adaptive is on.
PermissionPromptDialog
The built-in Material dialog.
PermissionRequestOptions
Overrides for one request/requestMany call. null keeps the app-wide PermissionConfig value.
PermissionRequiredView
The built-in fallback for PermissionGate: what is needed, why, and one button that does the right thing for the current state.
PermissionResult
The outcome of checking or requesting one AppPermission.
PermissionResults
The outcome of checking or requesting several permissions together.
PermissionStore
Where PermissionHistory lives.
PermissionStrings
Every generic string the built-in dialogs show. Override any subset for wording or translation; permission-specific wording lives in PermissionTexts.
PermissionTexts
Wording and icon for one permission. Every field is optional; anything left null falls back to defaultPermissionTexts, then to the generic PermissionStrings template.
PermissionWithService
A special kind of permission, used to access a service.
PlatformInfo
What the resolver needs to know about the device to pick the right native permission.
SettingsReturnWaiter
Opens a settings screen and waits until the user is back in the app, so the flow can re-check what they changed there.

Enums

AppPermission
What the app wants to use, as the user would describe it, rather than the raw OS permission that happens to back it on a given device.
PermissionDialogAction
What the user did with a dialog.
PermissionDialogKind
Which moment of the flow a dialog is for.
PermissionOS
The operating systems this package distinguishes.
PermissionPresentation
How a dialog is put on screen.
PermissionState
Where a permission stands, from the app's point of view.
PermissionStatus
Defines the state of a Permission.
RationaleMode
When to explain a permission before the system prompt appears.
ServiceSettingsType
Which system settings screen to open for a switched-off service.
ServiceStatus
Defines the different states a service can be in.

Extensions

AppPermissionActions on AppPermission
The short way to use the package — no instance, no setup:
AppPermissionListActions on Iterable<AppPermission>
Several permissions at once:
PermissionStateGetters on PermissionState
Convenience getters for PermissionState.

Functions

defaultPermissionTexts(AppPermission permission) → PermissionTexts
The built-in English name, rationale, icon and — where the generic steps would mislead — Settings steps for each permission.
fillTemplate(String template, Map<String, String> values) → String
Fills {key} placeholders from values; unknown placeholders are left as they are rather than throwing, so a typo in a translation shows up on screen instead of crashing the dialog.
resolvePermission(AppPermission permission, PlatformInfo info) → PermissionPlan
The built-in mapping. Public so an override can delegate to it for everything it does not special-case.

Typedefs

PermissionDialogWidgetBuilder = Widget Function(BuildContext context, PermissionDialogData data, void respond(PermissionDialogAction action))
Replaces the built-in prompt's widget; the package still presents it, in data.presentation. For a dialog the widget is the route's whole content, so return a Dialog; for a sheet or snack bar it is placed inside one, so return just the content. Call respond once with the user's choice — it closes the prompt.
PermissionFallbackBuilder = Widget Function(BuildContext context, PermissionResults results, VoidCallback request, VoidCallback openSettings)
Builds what to show while a gate's permissions are not all allowed. request runs the full request flow; openSettings goes straight to Settings and re-checks on return.
PermissionPlanResolver = PermissionPlan? Function(AppPermission permission, PlatformInfo platform)
Maps a capability to a plan for the device it runs on.
PermissionPresenter = Future<PermissionDialogAction?> Function(BuildContext context, PermissionDialogData data)
Replaces the whole presentation: show anything you like — your design system's dialog, a full-screen page, a toast — and complete with the user's choice. null counts as PermissionDialogAction.dismissed — for a rationale that means "not now", and the system prompt is skipped.
PermissionStringsBuilder = PermissionStrings Function(BuildContext context)
Picks strings for the current locale.
PermissionTextsBuilder = PermissionTexts? Function(BuildContext context, AppPermission permission)
Picks per-permission texts for the current locale. Return null for the defaults.