updateSelectState method
Implementation
updateSelectState(List<DateTime> selectedDates) {
if (selectedDates.length == 1) {
for (var day in days) {
if (selectedDates.first.year == day.dateTime.year &&
selectedDates.first.month == day.dateTime.month &&
selectedDates.first.day == day.dateTime.day) {
day.isSelected = true;
day.isInRange = false;
day.isSelectedStart = true;
day.isSelectedEnd = true;
} else {
day.isSelected = false;
day.isInRange = false;
day.isSelectedStart = false;
day.isSelectedEnd = false;
}
}
} else if (selectedDates.length == 2) {
for (var day in days) {
bool isStart = selectedDates.first.year == day.dateTime.year &&
selectedDates.first.month == day.dateTime.month &&
selectedDates.first.day == day.dateTime.day;
bool isEnd = selectedDates.last.year == day.dateTime.year &&
selectedDates.last.month == day.dateTime.month &&
selectedDates.last.day == day.dateTime.day;
if (isStart || isEnd) {
day.isSelected = true;
day.isInRange = false;
day.isSelectedStart = isStart;
day.isSelectedEnd = isEnd;
} else if (day.dateTime.isAfter(selectedDates.first) &&
day.dateTime.isBefore(selectedDates.last)) {
day.isSelected = false;
day.isInRange = true;
day.isSelectedStart = false;
day.isSelectedEnd = false;
} else {
day.isSelected = false;
day.isInRange = false;
day.isSelectedStart = false;
day.isSelectedEnd = false;
}
}
}
}