listScheduledNotifications method

  1. @override
Future<List<NotificationModel>> listScheduledNotifications()
override

List all active scheduled notifications.

Implementation

@override
Future<List<NotificationModel>> listScheduledNotifications() async {
  List<NotificationModel> scheduledNotifications = [];
  List<Object>? returned =
      await methodChannel.invokeListMethod(CHANNEL_METHOD_LIST_ALL_SCHEDULES);
  if (returned != null) {
    for (Object object in returned) {
      if (object is Map) {
        try {
          NotificationModel notificationModel =
              NotificationModel().fromMap(Map<String, dynamic>.from(object))!;
          scheduledNotifications.add(notificationModel);
        } catch (e) {
          return [];
        }
      }
    }
  }
  return scheduledNotifications;
}