Articles in this section
Category / Section

How to get the recurrence date collection in the Flutter Calendar

1 min read

In the Flutter Event Calendar, you can get the recurrence appointment date collection by using the getRecurrenceDateTimeCollection property of the calendar.

In initState(), set the default values for calendar.

String? _recurrenceRule = 'FREQ=DAILY;INTERVAL=2;UNTIL=20210810';
DateTime? _startTime =;

Using onPressed callback of the RaisedButton, show the alert dialog get the date collection of the recurrence rule.

child: Column(
  children: [
      child: new RaisedButton(
        onPressed: _showDialog,
        child: new Text("Get Recurrence date collections"),
        child: SfCalendar(
      view: CalendarView.month,
      dataSource: _getCalendarDataSource(),
_AppointmentDataSource _getCalendarDataSource() {
  List<Appointment> appointments = <Appointment>[];
      startTime: _startTime!,
      endTime: _startTime!.add(Duration(hours: 1)),
      subject: 'Meeting',
      recurrenceRule: _recurrenceRule));
  return _AppointmentDataSource(appointments);

In this alert dialog get the recurrence date collections by using getRecurrenceDateCollection method of the calendar and show the date collection details in itemBuilder of the ListView.

_showDialog() async {
  List<DateTime> _dateCollection =
      SfCalendar.getRecurrenceDateTimeCollection(_recurrenceRule!, _startTime!);
  await showDialog(
    builder: (context) => new
      contentPadding: const EdgeInsets.all(16.0),
      content: ListView.builder(
          itemCount: _dateCollection.length,
          itemBuilder: (BuildContext context, int index) {
            return new Text(DateFormat('dd, MMMM yyyy')
      actions: <Widget>[
        new FlatButton(
            child: const Text('CANCEL'),
            onPressed: () {
        new FlatButton(
            child: const Text('OK'),
            onPressed: () {
    ), context: context,

View sample in GitHub

Recurrence gif



Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied