NotificationPermissionBottomSheet class
A bottom sheet for requesting notification permissions with customizable content.
This widget provides a user-friendly interface for requesting notification permissions, with appropriate messaging and actions based on the current permission state.
All text is fully customizable for localization.
Usage
Simple usage with defaults:
await NotificationPermissionBottomSheet.show(context);
Customized usage with localization:
await NotificationPermissionBottomSheet.show(
context,
title: AppLocalizations.of(context).notificationPermissionTitle,
description: AppLocalizations.of(context).notificationPermissionDescription,
allowButtonText: AppLocalizations.of(context).allow,
declineButtonText: AppLocalizations.of(context).notNow,
deniedDialogTitle: AppLocalizations.of(context).notificationsDeniedTitle,
deniedDialogMessage: AppLocalizations.of(context).notificationsDeniedMessage,
openSettingsButtonText: AppLocalizations.of(context).openSettings,
maybeLaterButtonText: AppLocalizations.of(context).maybeLater,
onResult: (status) {
if (status == NotificationPermissionStatus.authorized) {
// Handle success
}
},
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- NotificationPermissionBottomSheet
- Available extensions
Constructors
- NotificationPermissionBottomSheet({Key? key, String title = 'Enable Notifications', String description = 'Stay informed with notifications about important updates and activity.', String allowButtonText = 'Allow Notifications', String declineButtonText = 'Not Now', String deniedDialogTitle = 'Notifications Disabled', String deniedDialogMessage = 'To enable notifications, please go to Settings and allow notifications for this app.', String openSettingsButtonText = 'Open Settings', String maybeLaterButtonText = 'Maybe Later', Color? primaryColor, Color? backgroundColor, Widget? icon, dynamic onResult(NotificationPermissionStatus)?})
-
const
Properties
- allowButtonText → String
-
final
- backgroundColor → Color?
-
final
- declineButtonText → String
-
final
- deniedDialogMessage → String
-
final
- deniedDialogTitle → String
-
final
- description → String
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget?
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maybeLaterButtonText → String
-
final
- onResult → dynamic Function(NotificationPermissionStatus)?
-
final
- openSettingsButtonText → String
-
final
- primaryColor → Color?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title → String
-
final
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
-
withUpdateDebugControls(
) → Widget -
Available on Widget, provided by the AppUpdateDebugExtension extension
Wraps this widget with debug controls if in debug mode
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
show(
BuildContext context, {String title = 'Enable Notifications', String description = 'Stay informed with notifications about important updates and activity.', String allowButtonText = 'Allow Notifications', String declineButtonText = 'Not Now', String deniedDialogTitle = 'Notifications Disabled', String deniedDialogMessage = 'To enable notifications, please go to Settings and allow notifications for this app.', String openSettingsButtonText = 'Open Settings', String maybeLaterButtonText = 'Maybe Later', Color? primaryColor, Color? backgroundColor, Widget? icon, dynamic onResult(NotificationPermissionStatus)?}) → Future< NotificationPermissionStatus?> - Shows the notification permission bottom sheet.