weekDays property
Defines the weekdays for an Appointment to recur.
The Appointment will recur on the WeekDays set to this property, when the recurrenceType set as RecurrenceType.weekly.
See also:
- WeekDays, to know more about the available week days to define.
- recurrenceType, which used to define the the type of the recurring event.
Widget build(BuildContext context) {
return Container(
child: SfCalendar(
view: CalendarView.day,
dataSource: _getCalendarDataSource(),
),
);
}
class DataSource extends CalendarDataSource {
DataSource(List<Appointment> source) {
appointments = source;
}
}
DataSource _getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[];
RecurrenceProperties recurrence =
RecurrenceProperties(startDate: DateTime.now());
List<WeekDays> days = <WeekDays>[];
days.add(WeekDays.monday);
days.add(WeekDays.wednesday);
days.add(WeekDays.friday);
days.add(WeekDays.saturday);
recurrence.weekDays = days;
recurrence.recurrenceType = RecurrenceType.weekly;
recurrence.endDate = DateTime.now().add(Duration(days: 10));
recurrence.recurrenceRange = RecurrenceRange.endDate;
appointments.add(
Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(
Duration(hours: 2)),
isAllDay: true,
subject: 'Meeting',
color: Colors.blue,
startTimeZone: '',
endTimeZone: '',
recurrenceRule: SfCalendar.generateRRule(recurrence,
DateTime.now(), DateTime.now().add(Duration(hours: 2)))
));
return DataSource(appointments);
}
Implementation
List<WeekDays> weekDays;