How to customize the time label in the Flutter Calendar?
In the Flutter Event Calendar, you can customize the time label text using the `timeFormat` property of `TimeSlotViewSettings` in `SfCalendar`.
STEP 1: In initState(), Initialize the default values for calendar view and custom text for the time label:
CalendarView _calendarView; String _customTimeLabelText; @override void initState() { _calendarView = CalendarView.week; _customTimeLabelText='Cell'; super.initState(); }
STEP 2: Set the ‘timeRulerSize’ value as 0, to hide the time labels.
body: Column( children: <Widget>[ Expanded( child: SfCalendar( view: _calendarView, timeSlotViewSettings: TimeSlotViewSettings( timeRulerSize: 0, ), ), ), ], ),
|
|
STEP 3: Assign the custom time label text to the `timeFormat` property of the `TimeSlotViewSettings`. You can combine it with time format patterns for dynamic values:
body: Column( children: <Widget>[ Expanded( child: SfCalendar( viewHeaderStyle: ViewHeaderStyle(backgroundColor: viewHeaderColor), backgroundColor: calendarColor, view: CalendarView.week, controller: _controller, allowedViews: [ CalendarView.day, CalendarView.week, CalendarView.workWeek, CalendarView.timelineDay, CalendarView.timelineWeek, CalendarView.timelineWorkWeek ], dataSource: getCalendarDataSource(), timeSlotViewSettings: TimeSlotViewSettings( timelineAppointmentHeight: 500, timeRulerSize: 80, timeFormat: _customTimeLabelText! + ' hh', timeTextStyle: TextStyle( color: Colors.black, fontWeight: FontWeight.bold)), ), ), ], ),
Be careful when using DateTime format characters in your customization text. Any format characters will be interpreted as part of the time format.
For example, if you use 'hall' as your custom text, it will be displayed as 1AMll, 2AMll, 3AMll, etc. (where 'h' represents hour, 'a' represents AM/PM, and 'll' is treated as custom text).
Conclusion
I hope you enjoyed learning about how to customize the time label in the Flutter Calendar.
You can refer to
our Flutter Calendar feature tour page to know about its other groundbreaking
feature representations and documentation, and how to quickly get started for
configuration specifications. You can also explore our Flutter Calendar
example 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!