showImageNotification static method
Show notification with image (mobile/web only)
Note: Desktop platforms don't support images in notifications. On desktop, this will show a simple notification without the image.
Parameters:
title: Notification title (required)message: Notification message (required)imageUrl: URL of the image to display (required)
Example:
await UnifiedNotificationService.showImageNotification(
title: 'New Photo',
message: 'John shared a photo with you',
imageUrl: 'https://example.com/photo.jpg',
);
Implementation
static Future<void> showImageNotification({
required String title,
required String message,
required String imageUrl,
}) async {
if (!_isInitialized) {
if (kDebugMode) {
print(
'UnifiedNotificationService: Not initialized. Call initialize() first.',
);
}
return;
}
try {
if (_isDesktopPlatform()) {
// Desktop doesn't support images, show simple notification
if (kDebugMode) {
print(
'UnifiedNotificationService: Image notifications not supported on desktop, showing simple notification',
);
}
await showNotification(title: title, message: message);
} else {
// Use notification_master for mobile/web
await _notificationMaster.showImageNotification(
title: title,
message: message,
imageUrl: imageUrl,
);
}
} catch (e) {
if (kDebugMode) {
print(
'UnifiedNotificationService: Failed to show image notification: $e',
);
}
}
}