listScheduledNotifications method
Lists all active scheduled notifications.
This method returns a Future that resolves to a list of NotificationModel objects representing all active scheduled notifications. If there are no active scheduled notifications, the list will be empty.
This method can be used to get a list of all scheduled notifications in order to display them to the user or to cancel them programmatically.
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) {
NotificationModel? notificationModel =
NotificationModel().fromMap(Map<String, dynamic>.from(object));
if (notificationModel == null) continue;
scheduledNotifications.add(notificationModel);
}
}
}
return scheduledNotifications;
}