We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the month cell with appointment count in the Flutter event Calendar (SfCalendar)

Platform: Flutter |
Control: SfCalendar |
Published Date: January 22, 2021 |
Last Revised Date: January 22, 2021

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.

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,
  dataSource: _getCalendarDataSource(),
)

View sample in GitHub

custom cell gif

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon