How to show the appointment in agenda view using the programmatic date selection in the Flutter Calendar
In Flutter Date Range Picker, you can programmatically select the date and display the appointments in the agenda view using the `selectedDate` property of `CalendarController`.
STEP 1: In the `onViewChanged` callback, use the `selectedDate` property of the `CalendarController`, to show appointments of the selected date in the agenda view. you can programmatically set the `selectedDate` for all months.
void viewChanged(ViewChangedDetails viewChangedDetails) {
SchedulerBinding.instance!.addPostFrameCallback((duration) {
var midDate = (viewChangedDetails
.visibleDates[viewChangedDetails.visibleDates.length ~/ 2]);
if (midDate.month == DateTime
.now()
.month)
_calendarController.selectedDate = DateTime.now();
else {
_calendarController.selectedDate = DateTime(
midDate.year,
midDate.month,
01,
9,
0,
0,
);
}
});
}
STEP 2: Place the calendar inside the body of the Scaffold widget.
home: Scaffold(
body: SafeArea(
child: SfCalendar(
view: CalendarView.month,
controller: _calendarController,
monthViewSettings: MonthViewSettings(showAgenda: true),
dataSource: getCalendarDataSource(),
onViewChanged: viewChanged,
),
),
),
Conclusion
I hope you enjoyed learning about how to show the appointment in agenda view using the programmatic date selection in the Flutter Calendar.
You can refer to our Flutter Calender feature tour page to know about its other groundbreaking feature representations. You can also explore our Flutter Calendar documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!