moveToPreviousMonth method

void moveToPreviousMonth({
  1. bool needAnimation = false,
  2. Duration duration = const Duration(milliseconds: 500),
  3. Curve curve = Curves.ease,
})

Implementation

void moveToPreviousMonth(
    {bool needAnimation = false,
    Duration duration = const Duration(milliseconds: 500),
    Curve curve = Curves.ease}) {
  //    如果当前显示的是周视图的话,需要计算出第一个月的index后,调用weekController
  if (calendarLogic.expandStatus.value == false) {
    int currentMonth = weekList[weekController.page!.toInt()].month;
    for (int i = calendarLogic.calendarConfiguration.weekController!.page!
            .toInt();
        i >= 0;
        i--) {
      if (weekList[i].month != currentMonth &&
          weekList[i].isAfter(DateModel.fromDateTime(DateTime(
              calendarConfiguration.minYear,
              calendarConfiguration.minYearMonth)))) {
        calendarLogic.calendarConfiguration.weekController!.jumpToPage(i);
        break;
      }
    }
    return;
  }

  if ((calendarLogic.calendarConfiguration.monthController!.page!
          .toInt()) ==
      0) {
    LogUtil.log(
        TAG: this.runtimeType, message: "moveToPreviousMonth:当前是第一个月份");
    return;
  }
  DateTime targetDateTime = monthList[calendarLogic
              .calendarConfiguration.monthController!.page!
              .toInt() -
          1]
      .getDateTime();
  moveToCalendar(
      targetDateTime.year, targetDateTime.month, targetDateTime.day,
      needAnimation: needAnimation, duration: duration, curve: curve);
}