syncfusion / flutter-examples

This repository contains the Syncfusion Flutter UI widgets examples and the guide to use them.
Other
1.98k stars 775 forks source link

How to set TrailingAndLeadingDates Style when use cellBuilder in SfDateRangePicker #719

Closed 2e2ee95304418f96 closed 1 year ago

2e2ee95304418f96 commented 1 year ago

When I use cellBuilder and enable showTrailingAndLeadingDates, but I can't find a way to set the style of TrailingAndLeadingDates.

Indumathi1195R commented 1 year ago

Hi,

As per the shared information, we have checked and your requirement is "Style the trailing and leading dates using cell builder in SfDateRangePicker". We have prepared the simple sample for the same. Please find the sample from the following link.

Sample link: cellbuilder.zip

Also please find the code snippet for the same.

  Widget cellBuilder(BuildContext context, DateRangePickerCellDetails details) {

    DateTime midDate = details.visibleDates[details.visibleDates.length ~/ 2];

    if (details.date.month != midDate.month) {
      return Container(
        child: Text(details.date.day.toString()),
        color: Colors.green,
      );
    } else {
      return Container(
        child: Text(details.date.day.toString()),
        color: Colors.red,
      );
    }
  }

We hope that this helps you. Please let us know if you need further assistance.