daysMaker method
Implementation
List<Widget> daysMaker(BuildContext context) {
int currentMonth = CalendarUtils.getPartByInt(format: PartFormat.MONTH);
int currentYear = CalendarUtils.getPartByInt(format: PartFormat.YEAR);
final headersStyle = HeaderOptions.of(context);
List<Widget> days = [
SizedBox(
width: DayOptions.of(context).compactMode
? 40
: headersStyle.weekDayStringType == WeekDayStringTypes.FULL
? 80
: 60)
];
int day = dayIndex;
CalendarUtils.getDays(headersStyle.weekDayStringType, currentMonth)
.forEach((index, weekDay) {
var selected = index == day;
bool isBeforeToday =
CalendarUtils.isBeforeThanToday(currentYear, currentMonth, index);
bool isAfterToday =
CalendarUtils.isAfterToday(currentYear, currentMonth, index);
bool isToday = CalendarUtils.isToday(currentYear, currentMonth, index);
bool isWeekStartDate = false, isWeekEndDate = false;
bool? isInBetweenWeekDate = false;
if (weekStartDate != null && weekEndDate != null) {
DateTime currentDateTime = DateTime(currentYear, currentMonth, index);
isWeekStartDate = currentDateTime.isAtSameMomentAs(weekStartDate!);
isWeekEndDate = currentDateTime.isAtSameMomentAs(weekEndDate!);
isInBetweenWeekDate =
currentDateTime.isBetween(weekStartDate!, weekEndDate!);
}
days.add(Day(
day: index,
isToday: isToday,
isWeekStartDate: isWeekStartDate,
isWeekEndDate: isWeekEndDate,
isInBetweenWeekDate: isInBetweenWeekDate!,
dayStyle: DayStyle(
compactMode: DayOptions.of(context).compactMode,
enabled: (DayOptions.of(context).disableDaysBeforeNow
? !isBeforeToday
: DayOptions.of(context).disableDaysAfterNow
? !isAfterToday
: true),
selected: selected,
useUnselectedEffect: false,
useDisabledEffect: DayOptions.of(context).disableDaysBeforeNow
? isBeforeToday
: DayOptions.of(context).disableDaysAfterNow
? isAfterToday
: false,
),
weekDay: weekDay,
onCalendarChanged: () {
CalendarUtils.goToDay(index);
onCalendarChanged?.call();
},
));
});
days.add(
SizedBox(
width: DayOptions.of(context).compactMode
? 40
: headersStyle.weekDayStringType == WeekDayStringTypes.FULL
? 80
: 60,
),
);
return days;
}