onSelectionChanged property

DateRangePickerSelectionChangedCallback? onSelectionChanged
final

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:


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;