CalendarDataSource<T extends Object?> class abstract

An object that maintains the data source for SfCalendar.

Allows to map the custom appointments to the Appointment and set the appointments collection to the SfCalendar to render the appointments on view.

Allows to add and remove an Appointment from the collection and also allows to reset the appointment collection for SfCalendar.

Note: This method must be implemented to get the data with business object type when drag and drop or appointment resizing enabled.

See also:

Widget build(BuildContext context) {
  return Container(
     child: SfCalendar(
       dataSource: _getCalendarDataSource(),

class MeetingDataSource extends CalendarDataSource {
 MeetingDataSource(List<_Meeting> source) {
   appointments = source;

 DateTime getStartTime(int index) {
   return appointments![index].from;

 DateTime getEndTime(int index) {
   return appointments![index].to;

 Color getColor(int index) {
   return appointments![index].background;

 String getEndTimeZone(int index) {
   return appointments![index].toZone;

 List<DateTime> getRecurrenceExceptionDates(int index) {
   return appointments![index].exceptionDates;

 String getRecurrenceRule(int index) {
   return appointments![index].recurrenceRule;

 String getStartTimeZone(int index) {
   return appointments![index].fromZone;

 String getSubject(int index) {
   return appointments![index].title;

 bool isAllDay(int index) {
   return appointments![index].isAllDay;

class _Meeting {
     {required this.from,
     required this.background,
 DateTime from;
 DateTime to;
 String title;
 bool isAllDay;
 Color background;
 String fromZone;
 String toZone;
 String recurrenceRule;
 List<DateTime>? exceptionDates;

final DateTime date =;
 MeetingDataSource _getCalendarDataSource() {
   List<_Meeting> appointments = <_Meeting>[];
    from: date,
    to: date.add(const Duration(hours: 1)),
    title: 'General Meeting',
    isAllDay: false,
    fromZone: '',
    toZone: '',
    recurrenceRule: '',
    exceptionDates: null

   return MeetingDataSource(appointments);




appointments List?
Tha collection of appointments to be rendered on SfCalendar.
read / write
hashCode int
The hash code for this object.
resources List<CalendarResource>?
The collection of resource to be displayed in the timeline views of SfCalendar.
read / write
runtimeType Type
A representation of the runtime type of the object.


addListener(CalendarDataSourceCallback listener) → void
Calls the listener every time the collection in the CalendarDataSource changed
convertAppointmentToObject(T customData, Appointment appointment) → T?
Converts the Appointment data to the custom business object data.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener and removeListener will throw after the object is disposed).
getColor(int index) Color
Maps the custom appointments color to the Appointment.
getEndTime(int index) DateTime
Maps the custom appointments end time to the Appointment.
getEndTimeZone(int index) String?
Maps the custom appointments end time zone to the Appointment.
getId(int index) Object?
Maps the custom appointments id to the Appointment.
getLocation(int index) String?
Maps the custom appointments location to the Appointment.
getNotes(int index) String?
Maps the custom appointments notes to the Appointment.
getOccurrenceAppointment(Object? patternAppointment, DateTime date, String calendarTimeZone) Appointment?
Returns the occurrence appointment for the given pattern appointment at the specified date.
getPatternAppointment(Object? occurrenceAppointment, String calendarTimeZone) Object?
Returns the Pattern appointment for the provided occurrence appointment.
getRecurrenceExceptionDates(int index) List<DateTime>?
Maps the custom appointments recurrenceExceptionDates to the Appointment
getRecurrenceId(int index) Object?
Maps the custom appointments recurrence id to the Appointment.
getRecurrenceRule(int index) String?
Maps the custom appointments recurrence rule to the Appointment.
getResourceIds(int index) List<Object>?
Maps the custom appointment resource ids to the Appointment resource ids.
getStartTime(int index) DateTime
Maps the custom appointments start time to the Appointment.
getStartTimeZone(int index) String?
Maps the custom appointments start time zone to the Appointment.
getSubject(int index) String
Maps the custom appointments subject to the Appointment.
getVisibleAppointments(DateTime startDate, String calendarTimeZone, [DateTime? endDate]) List<Appointment>
Returns the appointments in the specified date range.
handleLoadMore(DateTime startDate, DateTime endDate) Future<void>
Called when loadMoreAppointments function is called from the loadMoreWidgetBuilder. Call the notifyListeners to notify the calendar for data source changes.
isAllDay(int index) bool
Maps the custom appointments isAllDay to the Appointment.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
notifyListeners(CalendarDataSourceAction type, List data) → void
Call all the registered listeners.
removeListener(CalendarDataSourceCallback listener) → void
remove the listener used for notify the data source changes.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.


operator ==(Object other) bool
The equality operator.