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,
           ),
       );
   }
}

Inheritance

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

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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