permission_builder

Last updated:

0 purchases

permission_builder Image
permission_builder Images
Add to Cart

Description:

permission builder

permissive_builder #
A Flutter package thats a wrapper around permission_handler which

exposes a set of builders which you can use to render widgets depending on the permission state.
exposes functions to askPermission and openSettings variably depending on the specific permission states
handles state management of the permissions using provider and uses freezed union types to provide a neat permission handling api.

class LocationPermissionWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PermissionBuilder(
permission: Permission.location, // can be any permission in Permission.

// We haven't ask for permission yet.
initialBuilder: (_, askPermissionFn) => FirstTimePermissionWidget(
requestPermissionFn: askPermissionFn,
),

// 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(
requestPermissionFn: askPermissionFn,
),
//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,
),
);
}
}
copied to clipboard
TODO #

Write tests.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.