How to use helper method of CalendarDataSource in Flutter Calendar?
In the Flutter Calendar, you can get the Pattern and Occurrence details of the recurrence appointment by using the getPatternAppointment and the getOccurrenceAppointment helper methods of CalendarDataSource.
STEP 1: In initState(), initialize the default values for calendar.
late _AppointmentDataSource _dataSource; late Appointment recurrenceApp; @override void initState() { _dataSource = _getCalendarDataSource(); super.initState(); }
STEP 2: Get the pattern appointment using the getPatternAppointment method.
Center( child: TextButton( onPressed: _showPatternAppointment, child: const Text("Click to get pattern appointment"), ), ), _showPatternAppointment() async { final Appointment patternAppointment = _dataSource.getPatternAppointment(recurrenceApp, '') as Appointment; await showDialog( builder: (context) => AlertDialog( contentPadding: const EdgeInsets.all(16.0), content: Text("Subject:" + patternAppointment.subject), actions: <Widget>[ TextButton( child: const Text('OK'), onPressed: () { Navigator.pop(context); }) ], ), context: context, ); }
STEP 3: Get occurrence appointment by using the getOccurrenceAppointment.
Center( child: TextButton( onPressed: _showOccurrenceAppointment, child: const Text("Click to get occurrence appointment"), ), ), _showOccurrenceAppointment() async { final DateTime date = DateTime.now(); final Appointment occurrenceAppointment = _dataSource .getOccurrenceAppointment(recurrenceApp, date, '') as Appointment; await showDialog( builder: (context) => AlertDialog( contentPadding: const EdgeInsets.all(16.0), content: Column( mainAxisSize: MainAxisSize.min, children: [ Text( "Subject: " + occurrenceAppointment.subject.toString(), ), Text( "Recurrence rule: " + occurrenceAppointment.recurrenceRule.toString(), textAlign: TextAlign.center, ), ], ), actions: <Widget>[ TextButton( child: const Text('OK'), onPressed: () { Navigator.pop(context); }) ], ), context: context, ); }
Conclusion
I hope you enjoyed learning how to use helper method of CalendarDataSource 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 Flatter 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!