We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize leading and trailing dates using cell builder in the Flutter Date Range Picker (SfDateRangePicker)

Platform: Flutter |
Control: SfDateRangePicker |
Published Date: June 18, 2021 |
Last Revised Date: June 18, 2021

In the Flutter date range picker, customize the leading and the trailing dates by using the cellBuilder property of the SfDateRangePicker.

Find out the middle date month. If the details (month) of the DateRangePickerCellDetails is not equal to the middle date month, then consider a different text style for that month.

child: SfDateRangePicker(
  monthViewSettings: DateRangePickerMonthViewSettings(
      showTrailingAndLeadingDates: true),
      (BuildContext context, DateRangePickerCellDetails details) {
    int middleDateMonth = details
        .visibleDates[details.visibleDates.length ~/ 2].month;
    if (details.date.month != middleDateMonth) {
      return Center(
        child: Container(
            child: Text(
          style: TextStyle(color: Colors.grey),
    } else {
      return Center(
        child: Container(
            child: Text(DateFormat('d').format(details.date))),

View sample in GitHub 

Flutter DateRangePicker leadtrail date customization


You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile