setMiddleIndex method Null safety

  1. @override
void setMiddleIndex(
  1. int index
)
override

Implementation

@override
void setMiddleIndex(int index) {
  super.setMiddleIndex(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();
  _currentRightIndex = currentTime.day - minDay;
}