recurrenceRule property
Recurs the Appointment on SfCalendar.
An Appointment will render the one appointment view for the given startTime and endTime in SfCalendar.
If it is not null
the appointment will be recurred multiple times based
on the RecurrenceProperties set to this property.
The recurrence rule can be generated using the SfCalendar.rRuleGenerator
method in Calendar
.
The recurrence rule can be directly set this property like 'FREQ=DAILY;INTERVAL=1;COUNT=3'.
Defaults to null.
See also:
- CalendarDataSource.getRecurrenceRule, which maps the custom business objects corresponding property to this property.
- RecurrenceProperties, which used to create the recurrence rule based on the values set to these properties.
- SfCalendar.generateRRule, which used to generate recurrence rule based on the RecurrenceProperties values.
- SfCalendar.getRecurrenceDateTimeCollection, to get the recurrence date time collection based on the given recurrence rule and start date.
- Knowledge base: How to use a negative value for bysetpos in rrule
- Knowledge base: How to get the recurrence date collection
- Knowledge base: How to add recurring appointments until specified date
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());
recurrence.recurrenceType = RecurrenceType.daily;
recurrence.interval = 2;
recurrence.recurrenceRange = RecurrenceRange.count;
recurrence.recurrenceCount = 10;
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
String? recurrenceRule;