timetable
timetable copied to clipboard
Support Recurring event
Hi,
Recurring event is very popular in our life.
Do we have any plan to support this?
Supporting recurring events in Timetable directly is out of scope. You can, however, use my package rrule to calculate occurrences of recurring events in a given time frame using recurrenceRule.getAllInstances(…)
, and then wrap each occurrence in its own event that is returned to Timetable. (It might make sense to cache the calculated occurrences using recurrenceRule.shouldCacheResults
.)
For example, using the new 1.0.0 pre-releases of Timetable, you could do something like this (not tested):
return TimetableConfig<BasicEvent>(
eventProvider: (interval) {
return myEvents.expand((event) {
// For each recurring event, we calculate all instances that intersect the requested interval:
final instances = event.recurrenceRule.getAllInstances(
start: event.start - event.duration,
after: interval.start,
includeAfter: true,
before: interval.end,
includeBefore: true,
);
// From each instance, we create a separate event for Timetable:
return instances.map((it) => event.copyWith(
id: '${event.id}-$it',
start: it,
end: it + event.duration,
));
});
},
// Other properties…
);