Articles in this section
Category / Section

How to add additional attributes in events in the Flutter Calendar?

2 mins read

In the Flutter event calendar, you can add the additional attributes for events by using custom appointments.

STEP 1: For adding custom appointments, create custom class Meeting with required fields. We must require two mandatory DateTime fields for events start and end time. In this sample id property added additionally.

class Meeting {
      this.isAllDay = false,});
  String eventName;
  DateTime from;
  DateTime to;
  Color background;
  bool isAllDay;
  int id;

STEP 2: Then, map the Meeting class properties to calendar by using the override method properties of CalendarDataSource.

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;
  String getSubject(int index) {
    return appointments[index].eventName;
  bool isAllDay(int index) {
    return appointments[index].isAllDay;
  Color getColor(int index) {
    return appointments[index].background;

STEP 3: Then, you can schedule an appointment for a day using the properties of Meeting class and use the additionally added properties.

child: SfCalendar(
  view: CalendarView.week,
  dataSource: getCalendarDataSource(),
  onTap: calendarTapped,
MeetingDataSource getCalendarDataSource() {
  List<Meeting> appointments = <Meeting>[];
      to: Duration(hours: 1)),
      eventName: 'Meeting',
      isAllDay: true,
      id: 1));
      from: Duration(hours: 4, days: -1)),
      to: Duration(hours: 5, days: -1)),
      eventName: 'Release Meeting',
      background: Colors.lightBlueAccent,
      id: 2));
      from: Duration(hours: 2, days: -2)),
      to: Duration(hours: 4, days: -2)),
      eventName: 'Performance check',
      background: Colors.amber,
      id: 5));
      from: Duration(hours: 6, days: -3)),
      to: Duration(hours: 7, days: -3)),
      eventName: 'Support',
      id: 3));
      from: Duration(hours: 6, days: 2)),
      to: Duration(hours: 7, days: 2)),
      eventName: 'Retrospective',
      background: Colors.purple,
      id: 4));
  return MeetingDataSource(appointments);

STEP 4: Implement the onTap callback of the Flutter calendar and you can get the additionally added property details and show the same in alert window.

void calendarTapped(CalendarTapDetails details) {
  if (details.targetElement == CalendarElement.appointment ||
      details.targetElement == CalendarElement.agenda) {
    final Meeting appointmentDetails = details.appointments[0];
    _subjectText = appointmentDetails.eventName;
    _dateText = DateFormat('MMMM dd, yyyy')
    _startTimeText =
        DateFormat('hh:mm a').format(appointmentDetails.from).toString();
    _endTimeText =
        DateFormat('hh:mm a').format(;
    if (appointmentDetails.isAllDay) {
      _timeDetails = 'All day';
    } else {
      _timeDetails = '$_startTimeText - $_endTimeText';
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Container(child: new Text('$_subjectText')),
            content: Container(
              height: 80,
              child: Column(
                children: <Widget>[
                    children: <Widget>[
                        style: TextStyle(
                          fontWeight: FontWeight.w400,
                          fontSize: 20,
                    children: <Widget>[
                          style: TextStyle(
                              fontWeight: FontWeight.w400, fontSize: 15)),
                    children: [
                      Text("Id:" +
            actions: <Widget>[
              new FlatButton(
                  onPressed: () {
                  child: new Text('close'))

View sample in GitHub 

additional attribute



I hope you enjoyed learning about how to add additional attributes in events in the Flutter Calendar.

You can refer to our Flutter Calendar feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation 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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied