initialSelectedRanges property

List<PickerDateRange>? initialSelectedRanges
final

The date ranges to initially select on the SfDateRangePicker.

If it is not null the SfDateRangePicker will select the range of dates that set to this property.

Defaults to null.

Note: If the controller and it's controller.selectedRanges property is not null then this property will be ignored and the widget render the selection for the ranges given in controller.selectedRanges.

It is only applicable when the selectionMode set as DateRangePickerSelectionMode.multiRange.

See also:


Widget build(BuildContext context) {
return MaterialApp(
     home: Scaffold(
       body: SfDateRangePicker(
         view: DateRangePickerView.month,
         selectionMode: DateRangePickerSelectionMode.multiRange,
         initialSelectedRanges: <PickerDateRange>[
           PickerDateRange(DateTime.now().subtract(Duration(days: 4)),
               DateTime.now().add(Duration(days: 4))),
           PickerDateRange(DateTime.now().add(Duration(days: 7)),
               DateTime.now().add(Duration(days: 14)))
         ],
       ),
     ),
   );
}

Implementation

final List<PickerDateRange>? initialSelectedRanges;