Articles in this section
Category / Section

How to customize the time label in the Flutter Calendar?

1 min read

In the Flutter Event Calendar, you can customize the time label text using the `timeFormat` property of `TimeSlotViewSettings` in `SfCalendar`.

STEP 1: In initState(), set the default values for calendar view, custom text for the time label.

CalendarView _calendarView;
String _customTimeLabelText;
 
@override
void initState() {
  _calendarView = CalendarView.week;
  _customTimeLabelText='Cell';
  super.initState();
}

STEP 2: Use the ‘timeRulerSize’ value as 0, to hide the time labels.

body: Column(
  children: <Widget>[
    Expanded(
      child: SfCalendar(
        view: _calendarView,
        timeSlotViewSettings: TimeSlotViewSettings(
          timeRulerSize: 0,
        ),
      ),
    ),
  ],
),

 

 

time ruler image

 

STEP 3: Assign the custom time label text to the `timeFormat` property of the `TimeSlotViewSettings` along with that you can add any time format data 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)),
      ),
    ),
  ],
),

 

Note:

If any `DateTime` format characters/string values used in the customization text which should not contain any global date time format characters.

e.g: `hall` will be customized to `1AMll`, `2AMll `, `3AMll` (h-hour, a- AM/PM followed by custom text ‘ll’).

 

View sample in GitHub

 

Flutter Calendar time label

 

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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied