onViewChanged property
Called when the current visible date changes in SfCalendar.
Called in the following scenarios when the visible dates were changed
- When calendar loaded the visible dates initially.
- When calendar view swiped to previous/next view.
- When calendar view changed, i.e: Month to day, etc..,
- When navigated to a specific date programmatically by using the
controller.displayDate
. - When navigated programmatically using
controller.forward
andcontroller.backward
.
The visible dates collection visible on view when the view changes available in the ViewChangedDetails.
See also:
- ViewChangedDetails, which contains the visible dates collection of the current visible view.
- initialDisplayDate, to display calendar on a desired date in initial.
- CalendarController.displayDate, to change the display date of calendar programmatically on run time.
- CalendarController.forward, to navigate to next view of calendar programmatically.
- CalendarController.backward, to navigate to previous view of calendar Programmatically.
- Knowledge base: How to update blackout dates using onViewChanged
- Knowledge base: How to clear the appointments in the month agenda view using onViewChange
- Knowledge base: How to add a special region dynamically using onTap, onViewChanged
Widget build(BuildContext context) {
return Container(
child: SfCalendar(
view: CalendarView.week,
onViewChanged: (ViewChangedDetails details){
List<DateTime> dates = details.visibleDates;
},
),
);
}
Implementation
final ViewChangedCallback? onViewChanged;