Programmatically Select Dates from a List of Dates

Hi there.

I'd like to know if it's possible to be able to programmatically select dates based on DateTime objects that are in a List?

For example, if I had a collection of DateTime objects like this:



Can the DateRangePicker select those dates, so that the outcome is like so?:


Thanks in advance.

3 Replies 1 reply marked as answer

IR Indumathi Ravichandran Syncfusion Team April 14, 2021 05:10 AM UTC

Hi Divine, 
 
Thank you for contacting Syncfusion support. 
 
Regarding Query:  it's possible to be able to programmatically select dates based on DateTime objects that are in a List? 
 
Yes, it is possible to select the dates programmatically by using the selectedRange property of the DateRangePickerController. We have UG document for the same. Please find the UG from the following link. 
 
 
Please find the code snippet for the same. 
 
final DateRangePickerController _controller = DateRangePickerController();

@override void initState() {
 
_controller.selectedRange=PickerDateRange(DateTime(2021, 04, 12), DateTime(2021, 04, 15));
 
super.initState();
}
body: Card(
  margin:
const EdgeInsets.fromLTRB(50, 150, 50, 110),
  child:
SfDateRangePicker(
    view: DateRangePickerView.
month,
    selectionMode: DateRangePickerSelectionMode.
range,
    controller:
_controller,
  ),
),
 
 
Screenshot: 
 
 
We hope that this helps you. Please let us know if you need further assistance. 
 
Regards, 
Indumathi R 


Marked as answer

DI Divine April 14, 2021 07:53 AM UTC

Great! Thanks a lot for your assistance!

I appreciate it.


IR Indumathi Ravichandran Syncfusion Team April 14, 2021 11:15 AM UTC

Hi Divine, 
 
Thank you for the update. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Indumathi R 


Loader.
Up arrow icon