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 (calendarProvider.expandStatus.value == false) {
    int currentMonth = weekList[weekController.page.toInt()].month;
    for (int i = calendarProvider.calendarConfiguration.weekController.page
            .toInt();
        i >= 0;
        i--) {
      if (weekList[i].month != currentMonth &&
          weekList[i].isAfter(DateModel.fromDateTime(DateTime(
              calendarConfiguration.minYear,
              calendarConfiguration.minYearMonth)))) {
        calendarProvider.calendarConfiguration.weekController.jumpToPage(i);
        break;
      }
    }
    return;
  }

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