selectedDate property Null safety

DateTime? selectedDate

The selected date in the SfDateRangePicker.

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


DateTime? get selectedDate => _selectedDate;
void selectedDate=(DateTime? date)

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

Note: If any date selected previously, will be removed and the selection will be drawn to the date given in this property.

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

It is only applicable when the DateRangePickerSelectionMode set as DateRangePickerSelectionMode.single.

See also:

class MyAppState extends State<MyApp> {
 DateRangePickerController _pickerController =

 void initState() {
   _pickerController.selectedDate =
                               days: 4)));

 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       body: SfDateRangePicker(
         controller: _pickerController,
         view: DateRangePickerView.month,
         selectionMode: DateRangePickerSelectionMode.single,
         showNavigationArrow: true,


set selectedDate(DateTime? date) {
  if (isSameDate(_selectedDate, date)) {

  _selectedDate = date;