Articles in this section
Category / Section

How to customize the schedule view month header using builder in the Flutter Calendar?

2 mins read

In the Flutter Event Calendar, you can customize the schedule view month header using the scheduleViewMonthHeaderBuilder property of the calendar.

STEP 1: Create a folder for images and add the required images in the folder and specify the images folder under the assets of the Pubspec file.

flutter:
 
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  assets:
    - images/

STEP 2: Use the required widget for the schedule view month header for customization. In this sample we are using Image widget for schedule view month header customization.

Widget scheduleViewHeaderBuilder(
    BuildContext buildContext, ScheduleViewMonthHeaderDetails details) {
  final String monthName = _getMonthName(details.date.month);
  return Stack(
    children: [
      Image(
          image: ExactAssetImage('images/' + monthName + '.png'),
          fit: BoxFit.cover,
          width: details.bounds.width,
          height: details.bounds.height),
      Positioned(
        left: 55,
        right: 0,
        top: 20,
        bottom: 0,
        child: Text(
          monthName + ' ' + details.date.year.toString(),
          style: TextStyle(fontSize: 18),
        ),
      )
    ],
  );
}

STEP 3: Based on the integer value updated the month string.

String _getMonthName(int month) {
  if (month == 01) {
    return 'January';
  } else if (month == 02) {
    return 'February';
  } else if (month == 03) {
    return 'March';
  } else if (month == 04) {
    return 'April';
  } else if (month == 05) {
    return 'May';
  } else if (month == 06) {
    return 'June';
  } else if (month == 07) {
    return 'July';
  } else if (month == 08) {
    return 'August';
  } else if (month == 09) {
    return 'September';
  } else if (month == 10) {
    return 'October';
  } else if (month == 11) {
    return 'November';
  } else {
    return 'December';
  }
}

STEP 4: Assign that widget to the scheduleViewMonthHeaderBuilder property of the calendar.

child: SfCalendar(
  view: CalendarView.schedule,
  dataSource: _getDataSource(),
  scheduleViewMonthHeaderBuilder: scheduleViewHeaderBuilder,
),

View sample in GitHub

 

customheadergif

 

 

Conclusion

I hope you enjoyed learning about how to customize the schedule view month header using builder 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 sign in to leave a comment
Access denied
Access denied