CalendarDataSource class

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.

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 {

 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. [...]
read-only, inherited
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.
read-only, inherited


addListener(CalendarDataSourceCallback listener) → void
Calls the listener every time the collection in the CalendarDataSource changed [...]
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). [...]
@mustCallSuper, inherited
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. [...]
getLocation(int index) → String
Maps the custom appointments location to the Appointment. [...]
getNotes(int index) → String
Maps the custom appointments notes to the Appointment. [...]
getRecurrenceExceptionDates(int index) → List<DateTime>
Maps the custom appointments recurrenceExceptionDates 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. [...]
isAllDay(int index) → bool
Maps the custom appointments isAllDay to the Appointment. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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. [...]
toString() → String
Returns a string representation of this object.


operator ==(Object other) → bool
The equality operator. [...]