selectedRange property

PickerDateRange? get selectedRange

selected date range in the SfDateRangePicker.

It is only applicable when the selectionMode set as DateRangePickerSelectionMode.range for other selection modes this property will return as null.

Implementation

PickerDateRange? get selectedRange => _selectedRange;
set selectedRange (PickerDateRange? range)

Selects the given date range programmatically in the SfDateRangePicker by checking that the range of dates falls in between the minimum and maximum date range.

Note: If any date range selected previously, will be removed and the selection will be drawn to the range of dates set to this property.

If it is not null the widget will render the date selection for the range set to this property, even the SfDateRangePicker.initialSelectedRange is not null.

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

See also:


class MyAppState extends State<MyApp> {
DateRangePickerController _pickerController = DateRangePickerController();

 @override
 void initState() {
   _pickerController.selectedRange = PickerDateRange(
       DateTime.now().add(Duration(days: 4)),
       DateTime.now().add(Duration(days: 5)));
   super.initState();
 }

 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       body: SfDateRangePicker(
         controller: _pickerController,
         view: DateRangePickerView.month,
         selectionMode: DateRangePickerSelectionMode.range,
       ),
     ),
   );
 }
}

Implementation

set selectedRange(PickerDateRange? range) {
  if (DateRangePickerHelper.isRangeEquals(_selectedRange, range)) {
    return;
  }

  _selectedRange = range;
  notifyPropertyChangedListeners('selectedRange');
}