In the Flutter Event Calendar, you can format the view header date and day by using the dayFormat and dateFormat properties in TimeSlotViewSettings. Inside the state initialize the default values for calendar. final CalendarController _controller = CalendarController(); String _dayFormat = 'EEE', _dateFormat = 'dd'; CalendarDataSource? _dataSource; @override initState() { _dataSource = _getCalendarDataSource(); super.initState(); } Using onViewChanged callback get the current calendar view, based on the calendar views, set the dayFormat and dateFormat. void viewChanged(ViewChangedDetails viewChangedDetails) { if (_controller.view == CalendarView.day) { SchedulerBinding.instance!.addPostFrameCallback((Duration duration) { if (_dayFormat != 'EEEEE' || _dateFormat != 'dd') { setState(() { _dayFormat = 'EEEEE'; _dateFormat = 'dd'; }); } else { return; } }); } else { SchedulerBinding.instance!.addPostFrameCallback((Duration duration) { if (_dayFormat != 'EEE' || _dateFormat != 'dd') { setState(() { _dayFormat = 'EEE'; _dateFormat = 'dd'; }); } else { return; } }); } } Assign _dayFormat and _dateFormat values to the calendar. child: SfCalendar( view: CalendarView.week, allowedViews: [ CalendarView.day, CalendarView.week, CalendarView.workWeek ], controller: _controller, dataSource: _dataSource, timeSlotViewSettings: TimeSlotViewSettings( dateFormat: _dateFormat, dayFormat: _dayFormat), onViewChanged: viewChanged, ),
|
This page will automatically be redirected to the sign-in page in 10 seconds.