displayDate property

DateTime? get displayDate

The first date of the current visible view, when the view set with the view other than CalendarView.month.

If the view set as CalendarView.month and the MonthViewSettings.numberOfWeeksInView property set with value less than or equal 4, this will return the first visible date of the current month.

If the view set as CalendarView.month and the MonthViewSettings.numberOfWeeksInView property set with value greater than 4, this will return the first date of the current visible month.

Implementation

DateTime? get displayDate => _displayDate;
set displayDate (DateTime? date)

Navigates to the given date programmatically without any animation in the SfCalendar by checking that the date falls in between the SfCalendar.minDate and SfCalendar.maxDate date range.

If the date falls beyond the SfCalendar.minDate and SfCalendar.maxDate the widget will move the widgets min or max date.

class MyAppState extends State<MyApp>{

CalendarController _calendarController = CalendarController();
@override
 initState(){
   _calendarController.selectedDate = DateTime(2022, 02, 05);
   _calendarController.displayDate = DateTime(2022, 02, 05);
   super.initState();
 }

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

Implementation

set displayDate(DateTime? date) {
  if (date == null) {
    return;
  }

  _displayDate = date;
  notifyPropertyChangedListeners('displayDate');
}