CleanCalendarController constructor
CleanCalendarController({
- required DateTime minDate,
- required DateTime maxDate,
- bool rangeMode = true,
- bool readOnly = false,
- DateTime? endDateSelected,
- DateTime? initialDateSelected,
- dynamic onDayTapped(
- DateTime date
- dynamic onRangeSelected()?,
- dynamic onAfterMaxDateTapped(
- DateTime date
- dynamic onPreviousMinDateTapped(
- DateTime date
- int weekdayStart = DateTime.monday,
- DateTime? initialFocusDate,
Implementation
CleanCalendarController({
required this.minDate,
required this.maxDate,
this.rangeMode = true,
this.readOnly = false,
this.endDateSelected,
this.initialDateSelected,
this.onDayTapped,
this.onRangeSelected,
this.onAfterMaxDateTapped,
this.onPreviousMinDateTapped,
this.weekdayStart = DateTime.monday,
this.initialFocusDate,
}) : assert(weekdayStart <= DateTime.sunday),
assert(weekdayStart >= DateTime.monday) {
final x = weekdayStart - 1;
weekdayEnd = x == 0 ? 7 : x;
DateTime currentDate = DateTime(minDate.year, minDate.month);
months.add(currentDate);
while (!(currentDate.year == maxDate.year &&
currentDate.month == maxDate.month)) {
currentDate = DateTime(currentDate.year, currentDate.month + 1);
months.add(currentDate);
}
if (initialDateSelected != null &&
(initialDateSelected!.isAfter(minDate) ||
initialDateSelected!.isSameDay(minDate))) {
onDayClick(initialDateSelected!, update: false);
}
if (endDateSelected != null &&
(endDateSelected!.isBefore(maxDate) ||
endDateSelected!.isSameDay(maxDate))) {
onDayClick(endDateSelected!, update: false);
}
}