onDayClick method

void onDayClick(
  1. DateTime date, {
  2. bool update = true,
})

Implementation

void onDayClick(DateTime date, {bool update = true}) {
  if (rangeMode) {
    if (rangeMinDate == null || rangeMaxDate != null) {
      rangeMinDate = date;
      rangeMaxDate = null;
    } else if (date.isBefore(rangeMinDate!)) {
      rangeMaxDate = rangeMinDate;
      rangeMinDate = date;
    } else if (date.isAfter(rangeMinDate!) || date.isSameDay(rangeMinDate!)) {
      rangeMaxDate = date;
    }
  } else {
    rangeMinDate = date;
    rangeMaxDate = date;
  }

  if (update) {
    notifyListeners();

    if (onDayTapped != null) {
      onDayTapped!(date);
    }

    if (onRangeSelected != null) {
      onRangeSelected!(rangeMinDate!, rangeMaxDate);
    }
  }
}