setMiddleIndex method

void setMiddleIndex(
  1. int index
)

Implementation

void setMiddleIndex(int index) {
  //adjust right
  int minMonth = _minMonthOfCurrentYear();
  int destMonth = minMonth + index;
  DateTime newTime;
  //change date time
  int dayCount = calcDateCount(currentTime.year, destMonth);
  newTime = currentTime.isUtc
      ? DateTime.utc(
          currentTime.year,
          destMonth,
          currentTime.day <= dayCount ? currentTime.day : dayCount,
        )
      : DateTime(
          currentTime.year,
          destMonth,
          currentTime.day <= dayCount ? currentTime.day : dayCount,
        );
  //min/max check
  if (newTime.isAfter(maxTime)) {
    currentTime = maxTime;
  } else if (newTime.isBefore(minTime)) {
    currentTime = minTime;
  } else {
    currentTime = newTime;
  }

  _fillRightLists();
  int minDay = _minDayOfCurrentMonth();
  _currentIndex[2] = currentTime.day - minDay;
}