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();
   _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,




displayDate DateTime
The first date of the current visible view, when the view set with the view other than CalendarView.month. [...]
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
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. [...]
backward() → void
Moves to the previous view programmatically with animation by checking that the previous view dates falls between the minimum and maximum date range. [...]
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). [...]
@mustCallSuper, inherited
forward() → void
Moves to the next view programmatically with animation by checking that the next view dates falls between the minimum and maximum date range. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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. [...]
toString() String
Returns a string representation of this object.


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