createNotification method
- required NotificationContent content,
- List<
NotificationActionButton> ? actionButtons, - List<
NotificationExtension> ? extensions,
LOCAL NOTIFICATION METHODS ********************************************* Creates a new notification with the specified content.
The content parameter is a NotificationContent object that represents
the content of the notification, including the title, body, icon, and other
details.
The optional actionButtons parameter is a list of
NotificationActionButton objects that represent the action buttons to be
displayed on the notification.
This method returns a Future that resolves to true if the notification
was successfully created, or false if an error occurred.
If the notification has no body or title, it will be created but not
displayed (i.e. it will be a "background" notification).
This method is typically used to create a new notification with the specified content. If an action button or buttons are provided, they will be displayed on the notification to allow the user to take specific actions in response to the notification.
The optional extensions let opt-in add-on packages attach extra data to
the notification — for example scheduling via the
awesome_notifications_schedules package (NotificationCalendar /
NotificationInterval), or per-language translations via the
awesome_notifications_localizations package (NotificationLocalizations).
Implementation
@override
Future<bool> createNotification({
required NotificationContent content,
List<NotificationActionButton>? actionButtons,
List<NotificationExtension>? extensions,
}) async {
_validateId(content.id!);
final Map<String, dynamic> data = NotificationModel(
content: content,
actionButtons: actionButtons,
).toMap();
for (final extension in extensions ?? const <NotificationExtension>[]) {
data.addAll(extension.toMap());
}
return await _build(data) ?? await engine.present(data);
}