isInRange static method

dynamic isInRange(
  1. CalendarDateTime? selectedDatetime,
  2. int year,
  3. int month,
  4. int day,
)

Implementation

static isInRange(
    CalendarDateTime? selectedDatetime, int year, int month, int day) {
  if (selectedDatetime?.year != year) return false;
  if (selectedDatetime?.month != null && selectedDatetime!.month > month)
    return false;
  if (selectedDatetime?.toMonth != null && selectedDatetime!.toMonth! < month)
    return false;
  if (selectedDatetime?.day != null &&
      selectedDatetime!.month == month &&
      selectedDatetime.day > day) return false;

  if (selectedDatetime?.toMonth != null) {
    if (selectedDatetime!.toDay != null &&
        selectedDatetime.toMonth == month &&
        selectedDatetime.toDay! < day) return false;
  } else {
    if (selectedDatetime!.toDay != null &&
        (selectedDatetime.month != month || selectedDatetime.toDay! < day))
      return false;
  }
  return true;
}