Articles in this section
Category / Section

How to customize agenda view height based on the Flutter Calendar widget height?

1 min read

In the Flutter Event Calendar, you can customize the agenda view height using the `agendaViewHeight` property of `MonthViewSettings` in the calendar widget.

STEP 1: Inside the state, initialize the default values.

final CalendarController _controller=CalendarController();
double _height=0.0;

STEP 2: Use the `MediaQuery` widget to get the height of the device. You can customize the agenda view height based on the height value from the `PopupMenuItem`.

appBar: AppBar(
  actions: <Widget>[
    PopupMenuButton<String>(
      icon: Icon(Icons.settings),
      itemBuilder: (BuildContext context) {
        return size.map((String choice) {
          return PopupMenuItem<String>(
            value: choice,
            child: Text('$choice',),
          );
        }).toList();
      },
      onSelected: (String value) {
        setState(() {
          if (value == '50') {
            _height = MediaQuery.of(context).size.height/2;
          } else if (value == '40') {
            _height = MediaQuery.of(context).size.height/3;
          } else if (value == '30') {
            _height = MediaQuery.of(context).size.height/4;
          } else if (value == '20') {
            _height = MediaQuery.of(context).size.height/5;
          }
        });
      },
    ),
  ],
),

STEP 3: Select the height value from the `PopupMenuItem` and assign the height value to the `agendaViewHeight` of `MonthViewSettings` of the calendar widget.

body: Column(
  children: <Widget>[
    Expanded(
      child: SfCalendar(
        view: CalendarView.month,
        controller: _controller,
        dataSource: getCalendarDataSource(),
        monthViewSettings:
        MonthViewSettings(showAgenda: true, agendaViewHeight: _height),
      ),
    ),
  ],
),

 View sample in Github

 

height1

height2

height3

 

Conclusion

I hope you enjoyed learning about how to customize agenda view height based on the Flutter Calendar widget height.

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?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied