This solution does not return appointments recurring forever and dates in the interval between the start date and the end date. The idea is whenever there are appointments on the selected date, list them for me.
|
recurrenceRule: 'FREQ=DAILY;INTERVAL=1;UNTIL=20200827T183000Z' recurrenceRule: 'FREQ=DAILY;INTERVAL=1' |
|
void viewChanged(ViewChangedDetails viewChangedDetails) { SchedulerBinding.instance.addPostFrameCallback((duration) { var midDate = (viewChangedDetails .visibleDates[viewChangedDetails.visibleDates.length ~/ 2]); if (midDate.month == DateTime .now() .month) _calendarController.selectedDate = DateTime.now(); }); } |

|
appointments.add(Appointment(
startTime: DateTime(2020,6,25,10,0,0), endTime: DateTime(2020,6,25,9,0,0), subject: 'Meeting', color: Colors.red, recurrenceRule: 'FREQ=DAILY;INTERVAL=1;UNTIL=20200827T183000Z' )); ///
appointments.add(Appointment(
startTime: DateTime(2020,6,25,9,0,0), endTime: DateTime(2020,6,25,11,0,0), subject: 'Meeting', color: Colors.red, recurrenceRule: 'FREQ=DAILY;INTERVAL=1;UNTIL=20200827T183000Z' )); |
List<Appointment> getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[];
appointments.add(Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 1)),
subject: 'Meeting',
color: Colors.green,
));
appointments.add(Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 2)),
subject: 'Planning',
color: Colors.red,
));
appointments.add(Appointment(
startTime: DateTime(2020, 5, 1, 9, 0, 0),
endTime: DateTime(2020, 5, 1, 10, 0, 0),
subject: 'Planning',
color: Colors.yellow,
));
appointments.add(Appointment(
startTime: DateTime.now().subtract(Duration(days: 1)),
endTime: DateTime.now().add(Duration(days: 3)),
subject: 'Recurrence',
color: Color(0xFFfb21f66),
recurrenceRule: 'FREQ=DAILY;INTERVAL=2;COUNT=10'));
return appointments;
}
final List<DateTime> dateCollection =
SfCalendar.getRecurrenceDateTimeCollection(
appointment.recurrence_rule, appointment.date);
for (int j = 0; j < dateCollection.length; j++) {
if (_isSameDate(dateCollection[j], viewStartDate)) {
appointmentDetails.add(appointment);
}
}
List<Appointment> getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[];
appointments.add(Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 1)),
subject: 'Meeting',
color: Colors.green,
));
appointments.add(Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 2)),
subject: 'Planning',
color: Colors.red,
));
appointments.add(Appointment(
startTime: DateTime(2020, 5, 1, 9, 0, 0),
endTime: DateTime(2020, 5, 1, 10, 0, 0),
subject: 'Planning',
color: Colors.yellow,
));
appointments.add(Appointment(
startTime: DateTime.now().subtract(Duration(days: 1)),
endTime: DateTime.now().add(Duration(days: 3)),
subject: 'Recurrence',
color: Color(0xFFfb21f66),
recurrenceRule: 'FREQ=WEEKLY;BYDAY=TH'));
return appointments;
}
|
List<Appointment> getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[]; appointments.add(Appointment( startTime: DateTime.now().subtract(Duration(days: 1)), endTime: DateTime.now().add(Duration(days: 3)), subject: 'Recurrence', color: Color(0xFFfb21f66), recurrenceRule: 'FREQ=WEEKLY;BYDAY=TH')); return appointments; } final List<DateTime> dateCollection =
SfCalendar.getRecurrenceDateTimeCollection( appointment.recurrenceRule, appointment.startTime, specificStartDate: appointment.startTime, specificEndDate: DateTime(2020, 8, 6, 9, 0, 0)); |