CalendarController class

An object that used for programmatic date navigation and date selection in SfCalendar.

A CalendarController served for several purposes. It can be used to selected dates programmatically on SfCalendar by using the selectedDate. It can be used to navigate to specific date by using the displayDate property.

Listening to property changes:

The CalendarController is a listenable. It notifies it's listeners whenever any of attached SfCalendar`s selected date, display date changed (i.e: selecting a different date, swiping to next/previous view] in in SfCalendar.

In SfCalendar the visible view can be navigated programmatically by using the forward and backward method.

Programmatic selection:

In SfCalendar selecting dates programmatically can be achieved by using the selectedDate which allows to select date on SfCalendar on initial load and in run time.

The CalendarController can be listened by adding a listener to the controller, the listener will listen and notify whenever the selected date, display date changed in the SfCalendar.

This example demonstrates how to use the CalendarController for SfCalendar.

class MyAppState extends State<MyApp>{

 CalendarController _calendarController = CalendarController();
   _calendarController.selectedDate = DateTime(2022, 02, 05);
   _calendarController.displayDate = DateTime(2022, 02, 05);

 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       body: SfCalendar(
         view: CalendarView.month,
         controller: _calendarController,




backward VoidCallback?
Moves to the previous view programmatically with animation by checking that the previous view dates falls between the minimum and maximum date range.
read / write
displayDate DateTime?
The first date of the current visible view, when the view set with the view other than CalendarView.month.
read / write
forward VoidCallback?
Moves to the next view programmatically with animation by checking that the next view dates falls between the minimum and maximum date range.
read / write
getCalendarDetailsAtOffset CalendarDetailsCallback?
Get the calendar details by given the Offset by using the getCalendarDetailsAtOffset method.
read / write
hashCode int
The hash code for this object.
runtimeType Type
A representation of the runtime type of the object.
selectedDate DateTime?
The selected date in the SfCalendar.
read / write
view CalendarView?
The displayed view of the SfCalendar.
read / write


addPropertyChangedListener(CalendarValueChangedCallback listener) → void
Calls the listener every time the controller's property changed.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener and removeListener will throw after the object is disposed).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
notifyPropertyChangedListeners(String property) → void
Call all the registered listeners.
removePropertyChangedListener(CalendarValueChangedCallback listener) → void
remove the listener used for notify the data source changes.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.


operator ==(Object other) bool
The equality operator.