onSelectionChanged property
Called when the new dates or date ranges selected.
The dates or ranges that selected when the selection changes available in the DateRangePickerSelectionChangedArgs.
See also:
- onViewChanged, callback which notifies when the current view visible dates changed on hijri date range picker.
- HijriDatePickerMonthViewSettings.enableSwipeSelection, which allows to select the cells on swipe when the selection mode set as DateRangePickerSelectionMode.range, DateRangePickerSelectionMode.multiRange, and DateRangePickerSelectionMode.extendableRange.
- selectionMode, which allows to customize the selection mode with available mode options.
- allowViewNavigation, which allows to navigate between views quickly,
and setting this property as
false
, allows to select the cells on year and decade view of hijri date range picker. - toggleDaySelection, which allows to deselect a date when the selection mode set as DateRangePickerSelectionMode.single.
- showActionButtons, which displays action buttons on bottom of date range picker, which allows to confirm and cancel the selection.
- onSubmit, callback which notifies when the selection confirmed through the ok button of showActionButtons.
- onCancel, callback which notifies when the selection canceled through the cancel button of showActionButtons.
- initialSelectedDate, which allows to select date programmatically initially on hijri date range picker.
- initialSelectedDates, which allows to list of select date programmatically initially on hijri date range picker.
- initialSelectedRange, which allows to select a range of dates programmatically initially on hijri date range picker.
- initialSelectedRanges, which allows to select a ranges of dates programmatically initially on hijri date range picker.
- HijriDatePickerController.selectedDate,which allows to select date programmatically dynamically on hijri date range picker.
- HijriDatePickerController.selectedDates, which allows to select dates programmatically dynamically on hijri date range picker.
- HijriDatePickerController.selectedRange, which allows to select range of dates programmatically dynamically on hijri date range picker.
- HijriDatePickerController.selectedRanges, which allows to select ranges of dates programmatically dynamically on hijri date range picker.
- Knowledge base: How to get the selected date
- Knowledge base: How to confirm or cancel the selection
- 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
class MyAppState extends State<MyApp> {
void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) {
if (args.value is HijriDateRange) {
final HijriDateTime rangeStartDate = args.value.startDate;
final HijriDateTime rangeEndDate = args.value.endDate;
} else if (args.value is HijriDateTime) {
final HijriDateTime selectedDate = args.value;
} else if (args.value is List<HijriDateTime>) {
final List<HijriDateTime> selectedDates = args.value;
} else {
final List<HijriDateRange> selectedRanges = args.value;
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('DatePicker demo'),
),
body: SfHijriDateRangePicker(
onSelectionChanged: _onSelectionChanged,
selectionMode: DateRangePickerSelectionMode.range,
initialSelectedRange: HijriDateRange(
HijriDateTime.now().subtract(Duration(days: 4)),
HijriDateTime.now().add(Duration(days: 3))),
),
));
}
}
Implementation
final DateRangePickerSelectionChangedCallback? onSelectionChanged;