initialSelectedDates property
The collection of dates to initially select on the SfDateRangePicker.
If it is not null
the SfDateRangePicker will select the dates that set
to this property.
Defaults to null.
Note: If the controller and it's controller.selectedDates
property
is not null
then this property will be ignored and the widget render the
selection for the dates given in controller.selectedDates
.
It is only applicable when the selectionMode set as DateRangePickerSelectionMode.multiple.
See also:
- initialDisplayDate, which used to navigate the date range picker to the specific date initially.
- initialSelectedDate, which allows to select date programmatically initially on date range picker.
- initialSelectedRange, which allows to select a range of dates programmatically initially on date range picker.
- initialSelectedRanges, which allows to select a ranges of dates programmatically initially on date range picker.
- DateRangePickerController.selectedDate,which allows to select date programmatically dynamically on date range picker.
- DateRangePickerController.selectedDates, which allows to select dates programmatically dynamically on date range picker.
- DateRangePickerController.selectedRange, which allows to select range of dates programmatically dynamically on date range picker.
- DateRangePickerController.selectedRanges, which allows to select ranges of dates programmatically dynamically on date range picker.
- selectionMode, which allows to customize the selection mode with available mode options.
- onSelectionChanged, the callback which notifies when the selection cell changed on the date range picker.
- showActionButtons, which allows to cancel of confirm the selection in the date range picker.
- onSubmit, the callback which notifies when the selected value confirmed through confirm button on date range picker.
- onCancel, the callback which notifies when the selected value canceled and reverted to previous confirmed value through cancel button on date range picker.
- Knowledge base: How to get the selected date
- Knowledge base: How to confirm or cancel the selection
- Knowledge base: How to change the selection radius
- Knowledge base: How to programmatically select the date
- Knowledge base: How to change the selection shape
- Knowledge base: How to customize the selected month cell
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SfDateRangePicker(
view: DateRangePickerView.month,
selectionMode: DateRangePickerSelectionMode.multiple,
initialSelectedDates: <DateTime>[
DateTime.now().add((Duration(days: 4))),
DateTime.now().add((Duration(days: 5))),
DateTime.now().add((Duration(days: 9))),
DateTime.now().add((Duration(days: 11)))
],
),
),
);
}
Implementation
final List<DateTime>? initialSelectedDates;