FakeSmartPermissionGateway class
In-memory SmartPermissionGateway for widget and unit tests.
Drives every SmartPermission flow (and PermissionGate) without
platform channels:
final fake = FakeSmartPermissionGateway()
..statuses[Permission.camera] = PermissionStatus.denied
..requestResults[Permission.camera] = [PermissionStatus.granted];
SmartPermission.config.gateway = fake;
// ... pump your widget, tap the button that requests the camera ...
expect(fake.requestedPermissions, [Permission.camera]);
SmartPermission.config.resetToDefaults();
- Implemented types
Constructors
-
FakeSmartPermissionGateway({Map<
Permission, PermissionStatus> ? statuses}) -
Creates a fake with optional initial
statuses.
Properties
- androidStatusSemantics ↔ bool
-
Mimics Android, where status reports
deniedfor a permanently denied permission and only a request returnspermanentlyDenied.getter/setter pair - canOpenSettings ↔ bool
-
What openAppSettings returns; set to false to simulate a platform
that cannot open settings (e.g. web).
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- openSettingsCalls ↔ int
-
How many times openAppSettings was called.
getter/setter pair
-
requestedPermissions
→ List<
Permission> -
Every permission passed to a native request, in order.
final
- requestError ↔ Object?
-
When set, request and requestMultiple throw this.
getter/setter pair
-
requestResults
→ Map<
Permission, List< PermissionStatus> > -
Statuses returned by successive native requests, per permission. When
a queue is empty (or absent) a request returns the current status.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusError ↔ Object?
-
When set, status throws this.
getter/setter pair
-
statuses
→ Map<
Permission, PermissionStatus> -
Current status per permission. Unlisted permissions are
denied. Updated by every request.final -
statusesAfterSettings
→ Map<
Permission, PermissionStatus> -
Applied to statuses when the user "returns from settings" (during
waitForSettingsReturn).
final
- waitForSettingsReturnCalls ↔ int
-
How many times waitForSettingsReturn was called.
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openAppSettings(
) → Future< bool> -
Opens the app settings screen. Returns false when unsupported.
override
-
request(
Permission permission) → Future< PermissionStatus> -
Requests
permissionnatively and returns the resulting status.override -
requestMultiple(
List< Permission> permissions) → Future<Map< Permission, PermissionStatus> > -
Requests all
permissionsin one native batch flow.override -
status(
Permission permission) → Future< PermissionStatus> -
Current status of
permission.override -
toString(
) → String -
A string representation of this object.
inherited
-
waitForSettingsReturn(
) → Future< void> -
Completes once the user has plausibly returned from the settings
screen, so a follow-up status check reflects their changes.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited