moveToCalendar method
void
moveToCalendar(})
Implementation
void moveToCalendar(int year, int month, int day,
{bool needAnimation = false,
Duration duration = const Duration(milliseconds: 500),
Curve curve = Curves.ease}) {
if (calendarLogic.expandStatus.value == true) {
DateModel dateModel = DateModel.fromDateTime(DateTime(year, month, 1));
//计算目标索引
int targetPage = monthList.indexOf(dateModel);
if (targetPage == -1) {
return;
}
if (calendarLogic.calendarConfiguration.monthController!.hasClients ==
false) {
return;
}
if (needAnimation) {
calendarLogic.calendarConfiguration.monthController
?.animateToPage(targetPage, duration: duration, curve: curve);
} else {
calendarLogic.calendarConfiguration.monthController
?.jumpToPage(targetPage);
}
} else {
DateModel dateModel = DateModel.fromDateTime(DateTime(year, month, 1));
//计算目标索引
int targetPage = 0;
for (int i = 0; i < weekList.length - 1; i++) {
DateModel first = weekList[i];
DateModel next = weekList[i + 1];
if (!first.isAfter(dateModel) && next.isAfter(dateModel)) {
targetPage = i;
return;
}
}
if (calendarLogic.calendarConfiguration.weekController!.hasClients ==
false) {
return;
}
if (needAnimation) {
calendarLogic.calendarConfiguration.weekController
?.animateToPage(targetPage, duration: duration, curve: curve);
} else {
calendarLogic.calendarConfiguration.weekController
?.jumpToPage(targetPage);
}
}
}