getNextDate method
Gets the next valid date for a notification schedule. The schedule
parameter is a valid NotificationSchedule model that specifies the
notification schedule. The optional fixedDate
parameter is a DateTime
value that represents the reference date to simulate a schedule in a
different time. If this parameter is omitted, the reference date will be
set to the current date and time.
This method returns a Future that resolves to a DateTime value that
represents the next valid date for the notification schedule. If the
notification schedule has expired or is invalid, the method will return
null
. If the notification schedule is a one-time event, the method will
return the event's date and time. If the notification schedule is a
repeating event, the method will return the next valid date and time for
the event.
Implementation
@override
Future<DateTime?> getNextDate(NotificationSchedule schedule,
{DateTime? fixedDate}) async {
fixedDate ??= DateTime.now().toUtc();
Map parameters = {
NOTIFICATION_INITIAL_FIXED_DATE:
AwesomeDateUtils.parseDateToString(fixedDate),
NOTIFICATION_SCHEDULE: schedule.toMap()
};
final String? nextDate = await methodChannel.invokeMethod(
CHANNEL_METHOD_GET_NEXT_DATE, parameters);
if (nextDate == null) return null;
return AwesomeDateUtils.parseStringToDate(nextDate)!;
}