showSystemAppNotification function
- ProviderContainer container,
- SystemAppNotification notification
Show a system-level app notification in the user's system tray.
Implementation
Future<void> showSystemAppNotification(
ProviderContainer container,
SystemAppNotification notification,
) async {
final plugin = await container.read(localNotificationPluginProvider.future);
final title =
Platform.isIOS ? notification.iOS.title : notification.android.title;
final body =
Platform.isIOS ? notification.iOS.body : notification.android.body;
await plugin.show(
notification.id,
title,
body,
NotificationDetails(
android: AndroidNotificationDetails(
notification.android.channelId,
notification.android.channelName,
channelDescription: notification.android.channelDescription,
importance: notification.android.importance,
priority: notification.android.priority,
tag: 'notifications',
color: KohlerTheme.energyDarkBlue,
styleInformation: BigTextStyleInformation(
notification.android.bigText,
contentTitle: notification.android.contentTitle,
summaryText: notification.android.summaryText,
),
),
iOS: const DarwinNotificationDetails(),
),
payload: notification.action != null
? jsonEncode(notification.action!.toJson())
: null,
);
}