CleanCalendarController constructor

CleanCalendarController({
  1. required DateTime minDate,
  2. required DateTime maxDate,
  3. bool rangeMode = true,
  4. bool readOnly = false,
  5. DateTime? endDateSelected,
  6. DateTime? initialDateSelected,
  7. dynamic onDayTapped(
    1. DateTime date
    )?,
  8. dynamic onRangeSelected(
    1. DateTime minDate,
    2. DateTime? maxDate
    )?,
  9. dynamic onAfterMaxDateTapped(
    1. DateTime date
    )?,
  10. dynamic onPreviousMinDateTapped(
    1. DateTime date
    )?,
  11. int weekdayStart = DateTime.monday,
  12. 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);
  }
}