show method
Displays a local notification with title, body, and optional payload.
Returns the integer ID assigned to the notification.
Example:
final id = await notifications.show(
title: 'Build Complete',
body: 'Your artifact is ready for download.',
channelId: 'builds',
);
Implementation
Future<int> show({
required String title,
required String body,
String? payload,
String? channelId,
String channelName = 'General',
NotificationImportance importance = NotificationImportance.high,
int? id,
}) async {
final notificationId = id ?? _idCounter++;
final notificationDetails = NotificationDetails(
android: AndroidNotificationDetails(
channelId ?? 'default_channel',
channelName,
importance: importance.importance,
priority: importance.priority,
),
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: true,
),
);
logger.info('BloomNotifications: Displaying notification [$notificationId] "$title"');
try {
await _plugin.show(
notificationId,
title,
body,
notificationDetails,
payload: payload,
);
} catch (e) {
logger.warn('BloomNotifications: Notification display note: $e');
}
return notificationId;
}