displayDate property
DateTime?
get
displayDate
The first date of the current visible view month, when the
MonthViewSettings.numberOfWeeksInView
set with default value 6.
If the MonthViewSettings.numberOfWeeksInView
property set with value
other then 6, this will return the first visible date of the current
month.
Implementation
DateTime? get displayDate => _displayDate;
set
displayDate
(DateTime? date)
Navigates to the given date programmatically without any animation in the SfDateRangePicker by checking that the date falls in between the SfDateRangePicker.minDate and SfDateRangePicker.maxDate date range.
If the date falls beyond the SfDateRangePicker.minDate and SfDateRangePicker.maxDate the widget will move the widgets min or max date.
See also:
- SfDateRangePicker.initialDisplayDate, which used to navigate the date range picker to the specific date initially.
- SfDateRangePicker.onViewChanged, the callback which notifies when the current view visible date changed on the date range picker.
- Knowledge base: How to do programmatic navigation
- Knowledge base: How to programmatically navigate to adjacent dates
- Knowledge base: How to programmatically navigate
class MyAppState extends State<MyApp> {
DateRangePickerController _pickerController = DateRangePickerController();
@override
void initState() {
_pickerController.displayDate = DateTime(2022, 02, 05);
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SfDateRangePicker(
controller: _pickerController,
view: DateRangePickerView.month,
selectionMode: DateRangePickerSelectionMode.single,
),
),
);
}
}
Implementation
set displayDate(DateTime? date) {
if (isSameDate(_displayDate, date)) {
return;
}
_displayDate = date;
notifyPropertyChangedListeners('displayDate');
}