askPermissionBottomSheet method
void
askPermissionBottomSheet({
- required String title,
- required String description,
- required String pathDetail,
- required VoidCallback openSettingsAction,
- required VoidCallback cancelAction,
- required VoidCallback closeAction,
- Color titleColor = Colors.black,
- Color subTitleColor = Colors.black,
Displays a bottom sheet requesting app permission with navigation to settings.
Shows a modal bottom sheet explaining why a permission is needed and providing options to open device settings or cancel. Uses GlobalBottomSheet for presentation.
Parameters:
title: The main heading explaining the permission request.description: Detailed explanation of why the permission is needed.pathDetail: Path or additional details about the permission (displayed in bold).openSettingsAction: Callback executed before opening app settings.cancelAction: Callback executed when the cancel button is pressed.closeAction: Callback executed when the close icon is tapped.titleColor: Color for the title text (defaults to black).subTitleColor: Color for description and path text (defaults to black).
The bottom sheet includes:
- Close button (top right)
- Title with auto-sizing text
- Description paragraph
- Path details in bold
- "Go to Settings" button that opens device settings via openAppSettings
- Cancel button
Uses GetX translations for button labels ('goToSettings'.tr and 'cancel'.tr).
Example:
askPermissionBottomSheet(
title: 'Camera Permission Required',
description: 'This app needs camera access to take photos of your documents.',
pathDetail: 'Settings > App > Permissions > Camera',
openSettingsAction: () => print('Opening settings'),
cancelAction: () => Get.back(),
closeAction: () => Get.back(),
);
Note: The callbacks are currently not being invoked correctly in the implementation.
They should be called as functions: openSettingsAction() instead of just openSettingsAction.
Implementation
void askPermissionBottomSheet({
required String title,
required String description,
required String pathDetail,
required VoidCallback openSettingsAction,
required VoidCallback cancelAction,
required VoidCallback closeAction,
Color titleColor = Colors.black,
Color subTitleColor = Colors.black,
}) {
return GlobalBottomSheet.show(SingleChildScrollView(
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Utils.commonWidgets
.addVerticalSpace(Utils.appConstants.zeroPointZeroTwo),
Padding(
padding: const EdgeInsets.only(left: 35, right: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.topRight,
child: IconButton(
iconSize: 30,
icon: const Icon(Icons.close),
onPressed: () {
closeAction;
} // null disables the button
),
),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AutoSizeText(
title,
maxLines: 1,
minFontSize: 12,
textAlign: TextAlign.justify,
style: TextStyle(
fontFamily:
Utils.appFontFamily.textMainFontBoldFamily,
color: titleColor,
fontSize: Utils.appFontFamily.textDateFontSize),
),
),
),
Text(
description,
textAlign: TextAlign.justify,
style: TextStyle(
fontFamily: Utils.appFontFamily.textMainFontRegular,
color: subTitleColor,
fontSize: 16),
),
Text(
pathDetail,
textAlign: TextAlign.start,
style: TextStyle(
fontFamily: Utils.appFontFamily.textMainFontBoldFamily,
color: subTitleColor,
fontSize: 16),
)
],
),
),
Utils.commonWidgets
.addVerticalSpace(Utils.appConstants.zeroPointZeroThree),
Padding(
padding: const EdgeInsets.only(left: 30, right: 30),
child: DefaultButton(
btnText: 'goToSettings'.tr,
onButtonPressed: () async {
openSettingsAction;
openAppSettings();
},
),
),
Utils.commonWidgets
.addVerticalSpace(Utils.appConstants.zeroPointZeroTwo),
Padding(
padding: const EdgeInsets.only(left: 30, right: 30),
child: DefaultButton(
btnText: 'cancel'.tr,
onButtonPressed: () {
cancelAction;
},
),
),
Utils.commonWidgets
.addVerticalSpace(Utils.appConstants.zeroPointZeroFour),
],
),
),
));
}