notify method
Future<void>
notify({
- required String title,
- required String body,
- NotificationPriority priority = NotificationPriority.normal,
- List<
NotificationAction> actions = const [], - Duration? autoHide,
- String? category,
Show a notification.
Implementation
Future<void> notify({
required String title,
required String body,
NotificationPriority priority = NotificationPriority.normal,
List<NotificationAction> actions = const [],
Duration? autoHide,
String? category,
}) async {
final notification = NeomageNotification(
id: 'notif_${DateTime.now().millisecondsSinceEpoch}',
title: title,
body: body,
priority: priority,
actions: actions,
autoHide: autoHide ?? const Duration(seconds: 5),
category: category,
);
_history.add(notification);
if (_history.length > _maxHistory) {
_history.removeAt(0);
}
for (final backend in _backends) {
if (await backend.isSupported()) {
await backend.show(notification);
_events.add(NotificationShownEvent(notification.id));
}
}
}