onViewChanged property Null safety

ViewChangedCallback? onViewChanged
final

Called when the current visible date changes in SfCalendar.

Called in the following scenarios when the visible dates were changed

  1. When calendar loaded the visible dates initially.
  2. When calendar view swiped to previous/next view.
  3. When calendar view changed, i.e: Month to day, etc..,
  4. When navigated to a specific date programmatically by using the controller.displayDate.
  5. When navigated programmatically using controller.forward and controller.backward.

The visible dates collection visible on view when the view changes available in the ViewChangedDetails.

See also: ViewChangedDetails.


Widget build(BuildContext context) {
   return Container(
     child: SfCalendar(
       view: CalendarView.week,
       onViewChanged: (ViewChangedDetails details){
         List<DateTime> dates = details.visibleDates;
       },
     ),
   );
 }

Implementation

final ViewChangedCallback? onViewChanged;