updateData method
void
updateData(
{ - bool isNext = false,
})
Implementation
void updateData({bool isNext = false}) {
int toCheck = this.current.currentMonth;
if (isNext) {
toCheck++;
this.current.daysInMonth = DateTime(this.current.currentYear, toCheck, 0)
.toUtc()
.difference(
DateTime(this.current.currentYear, this.current.currentMonth, 0))
.inDays;
if (this.current.currentMonth < 12) {
this.current.currentMonth++;
} else {
this.current.currentMonth = 1;
this.current.currentYear++;
}
} else {
toCheck--;
this.current.daysInMonth =
DateTime(this.current.currentYear, this.current.currentMonth - 1, 0)
.toUtc()
.difference(DateTime(this.current.currentYear, toCheck - 1, 0))
.inDays;
if (this.current.currentMonth > 1) {
this.current.currentMonth--;
} else {
this.current.currentMonth = 12;
this.current.currentYear--;
}
}
_data.add(this.current);
}