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 handle the appointment display mode in the Flutter Calendar

Platform: Flutter |
Control: SfCalendar |
Published Date: February 2, 2021 |
Last Revised Date: May 5, 2021

In the Flutter Event Calendar, you can handle the appointment display mode by using the appointmentDisplayMode property of MonthViewSettings.

Inside the state initialize the default values.

MonthAppointmentDisplayMode? _displayMode =
    MonthAppointmentDisplayMode.appointment;

Based on the selected value from the PopupMenuButton, you can change the display mode.

List<String> _appointmentDisplayModes = <String>[
  'Appointment',
  'Indicator',
  'None',
];
 
PopupMenuButton<String>(
  icon: Icon(Icons.party_mode),
  itemBuilder: (BuildContext context) {
    return _appointmentDisplayModes.map((String choice) {
      return PopupMenuItem<String>(
        value: choice,
        child: Text(choice),
      );
    }).toList();
  },
  onSelected: (String value) {
    setState(() {
      if (value == 'Appointment') {
        _displayMode = MonthAppointmentDisplayMode.appointment;
      } else if (value == 'Indicator') {
        _displayMode = MonthAppointmentDisplayMode.indicator;
      } else if (value == 'None') {
        _displayMode = MonthAppointmentDisplayMode.none;
      }
    });
  },
),

Set the _displayMode value to the appointmentDisplayMode property of the calendar.

child: SfCalendar(
  view: CalendarView.month,
  dataSource: _getCalendarDataSource(),
  monthViewSettings: MonthViewSettings(
    showAgenda: true,
      appointmentDisplayMode:
         _displayMode!),
),

View sample in GitHub

displaymodegif

 

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