PermissionBuilder class
class LocationPermissionWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PermissionBuilder(
permission: Permission.location, // can be any permission in Permission.
// We didn't ask for permission yet.
initialBuilder: (_, askPermissionFn) => FirstTimePermissionWidget(),
// Permission requested. Awaiting for user input. Will rebuild after user input
requestingBuilder: (_) => RequestingPermissionWidget(),
// User has granted us permission
grantedBuilder: (_) => PermissionGrantedWidget(),
// The OS restricts access, for example because of parental controls
restrictedBuilder: (_, askPermissionFn) => PermissionRestrictedWidget(),
//The user opted to never again see the permission request dialog for this app.
permanentlyDeniedBuilder: (_, askPermissionFn, openSettingsFn) => PermanentlyDeniedWidget(
requestPermissionFn: askPermissionFn,
openSettingsFn: openSettingsFn,
),
// User denied the permission once
deniedBuilder: (_, askPermissionFn, openSettingsFn) => PermissionDeniedWidget(
openSettingsFn: openSettingsFn,
requestPermissionFn: askPermissionFn,
),
);
}
}
Constructors
-
PermissionBuilder({Key? key, required Permission permission, bool lazy = false, required Widget initialBuilder(Future request), required Widget requestingBuilder, required Widget grantedBuilder, required Widget restrictedBuilder(Future request), required Widget permanentlyDeniedBuilder(Future retry, Future openAppSettings), required Widget deniedBuilder(Future retry, Future openAppSettings), PermissionService? permissionService})
-
Implement the builders here and specify the permission to be requested
Properties
-
deniedBuilder
→ Widget Function(Future retry, Future openAppSettings)
-
what to build when we have been denied permission once
final
-
grantedBuilder
→ Widget
-
what to build when we have been granted for permission
final
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
initialBuilder
→ Widget Function(Future request)
-
what to build when we haven't asked for permission yet
final
-
key
→ Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
lazy
→ bool
-
set to true to wait until user is prompted to grant permission
set to false to immediately request for permission when widget is built
final
-
permanentlyDeniedBuilder
→ Widget Function(Future retry, Future openAppSettings)
-
What to build when the user opted to never again see the permission request dialog for this app.
final
-
permission
→ Permission
-
Which permission to request. e.g location, calenda, camera
final
-
requestingBuilder
→ Widget
-
what to build when we have requested for permission and we're waiting for user response
final
-
restrictedBuilder
→ Widget Function(Future request)
-
What widget to show if the permission is restricted. Maybe by OS restricting access, for example because of parental controls
final
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited