We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the recurrence date collection in the Flutter event calendar (SfCalendar)

Platform: Flutter |
Control: SfCalendar |
Published Date: February 8, 2021 |
Last Revised Date: February 8, 2021

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;
DateTime _startTime;
void initState() {
  _startTime = DateTime.now();
  _recurrenceRule = 'FREQ=DAILY;INTERVAL=2;UNTIL=20210810';

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',
      color: Colors.blue,
      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(
    context: context,
    child: new AlertDialog(
      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: () {

View sample in GitHub

Recurrence gif



You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon