CalendarDatePicker constructor
- Key? key,
- required NepaliDateTime initialDate,
- required NepaliDateTime firstDate,
- required NepaliDateTime lastDate,
- NepaliDateTime? currentDate,
- required ValueChanged<
NepaliDateTime> onDateChanged, - ValueChanged<
NepaliDateTime> ? onDisplayedMonthChanged, - DatePickerMode initialCalendarMode = DatePickerMode.day,
- SelectableDayPredicate? selectableDayPredicate,
- BoxDecoration? selectedDayDecoration,
- BoxDecoration? todayDecoration,
- Widget dayBuilder()?,
Creates a calender date picker
It will display a grid of days for the initialDate
's month. The day
indicated by initialDate
will be selected.
The optional onDisplayedMonthChanged callback can be used to track the currently displayed month.
The user interface provides a way to change the year of the month being displayed. By default it will show the day grid, but this can be changed to start in the year selection interface with initialCalendarMode set to DatePickerMode.year.
The initialDate
, firstDate
, lastDate
, onDateChanged, and
initialCalendarMode must be non-null.
lastDate
must be after or equal to firstDate
.
initialDate
must be between firstDate
and lastDate
or equal to
one of them.
currentDate
represents the current day (i.e. today). This
date will be highlighted in the day grid. If null, the date of
NepaliDateTime.now()
will be used.
If selectableDayPredicate is non-null, it must return true
for the
initialDate
.
Implementation
CalendarDatePicker({
Key? key,
required NepaliDateTime initialDate,
required NepaliDateTime firstDate,
required NepaliDateTime lastDate,
NepaliDateTime? currentDate,
required this.onDateChanged,
this.onDisplayedMonthChanged,
this.initialCalendarMode = DatePickerMode.day,
this.selectableDayPredicate,
this.selectedDayDecoration,
this.todayDecoration,
this.dayBuilder,
}) : initialDate = utils.dateOnly(initialDate),
firstDate = utils.dateOnly(firstDate),
lastDate = utils.dateOnly(lastDate),
currentDate = utils.dateOnly(currentDate ?? NepaliDateTime.now()),
super(key: key) {
assert(
!this.lastDate.isBefore(this.firstDate),
'lastDate ${this.lastDate} must be on or after firstDate ${this.firstDate}.',
);
assert(
!this.initialDate.isBefore(this.firstDate),
'initialDate ${this.initialDate} must be on or after firstDate ${this.firstDate}.',
);
assert(
!this.initialDate.isAfter(this.lastDate),
'initialDate ${this.initialDate} must be on or before lastDate ${this.lastDate}.',
);
assert(
selectableDayPredicate == null ||
selectableDayPredicate!(this.initialDate),
'Provided initialDate ${this.initialDate} must satisfy provided selectableDayPredicate.',
);
}