How to Get the Recurrence Date Collection in Flutter Calendar?
In the Flutter 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.
Using onPressed callback of the RaisedButton, show the alert dialog get the date collection of the recurrence rule.
child: Column( children: [ Center( child: new RaisedButton( onPressed: _showDialog, child: new Text("Get Recurrence date collections"), ), ), Expanded( child: SfCalendar( view: CalendarView.month, dataSource: _getCalendarDataSource(), )) ], ), _AppointmentDataSource _getCalendarDataSource() { List<Appointment> appointments = <Appointment>[]; appointments.add(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( builder: (context) => 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') .format(_dateCollection[index]) .toString()); }), actions: <Widget>[ new FlatButton( child: const Text('CANCEL'), onPressed: () { Navigator.pop(context); }), new FlatButton( child: const Text('OK'), onPressed: () { Navigator.pop(context); }) ], ), context: context, ); }
I hope you enjoyed learning about how to get the recurrence date collection in Flutter Calendar.
You can refer to our Flutter Calendar feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Flutter Calendar example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!