selectedRanges property
List of selected ranges in the SfHijriDateRangePicker.
It is only applicable when the selectionMode
set as
DateRangePickerSelectionMode.multiRange for other selection modes
this property will return as null.
Implementation
List<HijriDateRange>? get selectedRanges => _selectedRanges;
Selects the given date ranges programmatically in the SfHijriDateRangePicker by checking that the ranges of dates falls in between the minimum and maximum date range.
If it is not null
the widget will render the date selection for the
ranges set to this property, even the
SfHijriDateRangePicker.initialSelectedRanges is not null.
Note: If any date ranges selected previously, will be removed and the selection will be drawn to the ranges of dates set to this property.
It is only applicable when the selectionMode
set as
DateRangePickerSelectionMode.multiRange.
See also:
- SfHijriDateRangePicker.initialSelectedRanges, which allows to select a ranges of dates programmatically initially on date range picker.
- selectedDate,which allows to select date programmatically dynamically on date range picker.
- selectedDates, which allows to select dates programmatically dynamically on date range picker.
- selectedRange, which allows to select range of dates programmatically dynamically on date range picker.
- SfHijriDateRangePicker.selectionMode, which allows to customize the selection mode with available mode options.
- SfHijriDateRangePicker.onSelectionChanged, the callback which notifies when the selected cell changed on the the date range picker.
- SfHijriDateRangePicker.showActionButtons, which allows to cancel of confirm the selection in the date range picker.
- SfHijriDateRangePicker.onSubmit, the callback which notifies when the selected value confirmed through confirm button on date range picker.
- SfHijriDateRangePicker.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 select a week
- Knowledge base: How to select previous or next dates bases on selected date
- Knowledge base: How to get the start and end date of the selected range
- Knowledge base: How to programmatically select the date
class MyAppState extends State<MyApp> {
HijriDatePickerController _pickerController = HijriDatePickerController();
@override
void initState() {
_pickerController.selectedRanges = <HijriDateRange>[
HijriDateRange(HijriDateTime.now().subtract(Duration(days: 4)),
HijriDateTime.now().add(Duration(days: 4))),
HijriDateRange(HijriDateTime.now().add(Duration(days: 11)),
HijriDateTime.now().add(Duration(days: 16)))
];
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SfHijriDateRangePicker(
controller: _pickerController,
view: HijriDatePickerView.month,
selectionMode: DateRangePickerSelectionMode.multiRange,
),
),
);
}
}
Implementation
set selectedRanges(List<HijriDateRange>? ranges) {
if (DateRangePickerHelper.isDateRangesEquals(_selectedRanges, ranges)) {
return;
}
_selectedRanges =
DateRangePickerHelper.cloneList(ranges)!.cast<HijriDateRange>();
notifyPropertyChangedListeners('selectedRanges');
}