showBigPictureNotificationHiddenLargeIcon static method

Future<void> showBigPictureNotificationHiddenLargeIcon(
  1. String? title,
  2. String? body,
  3. NotificationBody? notificationBody,
  4. String image,
  5. FlutterLocalNotificationsPlugin fln,
)

Implementation

static Future<void> showBigPictureNotificationHiddenLargeIcon(
    String? title,
    String? body,
    NotificationBody? notificationBody,
    String image,
    FlutterLocalNotificationsPlugin fln) async {
  List<AndroidNotificationAction> action = [];

  if (notificationBody != null) {
    if (notificationBody.growlytics!.buttons != null) {
      notificationBody.growlytics!.buttons!.forEach((element) {
        action.add(AndroidNotificationAction(
            element.label.toString(), element.label.toString(),
            showsUserInterface: true));
      });
    }
  }
  final String largeIconPath = await _downloadAndSaveFile(image, 'largeIcon');
  final String bigPicturePath =
      await _downloadAndSaveFile(image, 'bigPicture');
  final BigPictureStyleInformation bigPictureStyleInformation =
      BigPictureStyleInformation(
    FilePathAndroidBitmap(bigPicturePath),
    hideExpandedLargeIcon: true,
    contentTitle: title,
    htmlFormatContentTitle: true,
    summaryText: body,
    htmlFormatSummaryText: true,
  );

  final AndroidNotificationDetails androidPlatformChannelSpecifics =
      AndroidNotificationDetails(
    'growlytics',
    'growlytics',
    largeIcon: FilePathAndroidBitmap(largeIconPath),
    priority: Priority.max,
    playSound: true,
    actions: action,
    styleInformation: bigPictureStyleInformation,
    importance: Importance.max,
    // sound: const RawResourceAndroidNotificationSound('notification'),
  );
  final NotificationDetails platformChannelSpecifics = NotificationDetails(
      android: androidPlatformChannelSpecifics,
      iOS: DarwinNotificationDetails(
        attachments: [DarwinNotificationAttachment(largeIconPath)],
      ));
  await fln.show(0, title, body, platformChannelSpecifics,
      payload: notificationBody != null
          ? jsonEncode(notificationBody.toJson())
          : null);
}