Articles in this section
Category / Section

How to customize the month cell with appointment count in the Flutter Calendar

1 min read

In the Flutter Event Calendar, you can customize the calendar month cell with appointment count by using the monthCellBuilder property of the calendar. Use the required widget for cell customization with appointments count by using the MonthCellDetails.

Note:

Appointments will display on month cell builder widgets based on the appointment display mode

 

Widget monthCellBuilder(BuildContext context, MonthCellDetails details) {
  var length = details.appointments.length;
  if (details.appointments.isNotEmpty) {
    return Container(
      child: Column(
        children: <Widget>[
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                details.date.day.toString(),
                textAlign: TextAlign.center,
              ),
              Divider(color: Colors.transparent,),
              Text(
                '$length',
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.deepPurple),
              ),
              Divider(color: Colors.transparent,),
              Icon(
                Icons.event_available_rounded,
                color: Colors.red,
                size: 20,
              ),
            ],
          )
        ],
      ),
    );
  }
  return Container(
    child: Text(
      details.date.day.toString(),
      textAlign: TextAlign.center,
    ),
  );
}

Assign the customized widget to the monthCellBuilder property of the Flutter event calendar.

child: SfCalendar(
  view: CalendarView.month,
  monthCellBuilder: monthCellBuilder,
  monthViewSettings: MonthViewSettings(appointmentDisplayMode: MonthAppointmentDisplayMode.none),
  dataSource: _getCalendarDataSource(),
),

View sample in GitHub

custom cell gif

 

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