i am using date range picker for quite a time now but since 2-3 days i am facing a very strange issue regardless of the version I change. Even if i add the very basic code from your site -
Positioned( left: 20, top: 50, right: 20, bottom: 50, child: Container( color: Colors.white, height: screenWidth/2, width: screenWidth/2, child: Center( child: SfDateRangePicker( onSelectionChanged: _onSelectionChanged, selectionMode: DateRangePickerSelectionMode.range, initialSelectedRange: PickerDateRange( DateTime.now().subtract(const Duration(days: 4)), DateTime.now().add(const Duration(days: 3))), ), ), ), ),
i am getting calendrer like this either using directly or in container. enter image description here
Please let me know any possible reason and solution for this.
trying to display proper calendar in flutter app.
I had the same issue. I could fix it by implementing my own
cellBuilder
parameter in theSfDateRangePicker
like the followingwhere
You will end up building something not so beautiful like this:
If you want to modify the selected dates shape, border radious, color, etc. to have a nicer view, you will have to go further and create a
DateRangePickerController
, assign it in thecontroller
parameter, and use this controller to access the selected date cell inside thecellBuilder
by checkingdetails.date
is equal to_controller.selectedDate
and modify the BoxDecoration property of the container accordingly. Don't forget to change theSfDateRangePicker
parameter toselectionColor: Colors.transparent,
otherwise, when changing theboxDecoration
cell of the selected dates in thecellBuilder
you will still have the blue squared box over there.I hope this can help you. Here are some resources about it:
https://help.syncfusion.com/flutter/daterangepicker/builders