XBCalendarMonth constructor
XBCalendarMonth({})
Implementation
XBCalendarMonth(
{required this.year,
required this.month,
required DateTime? minEnableDateTime,
required DateTime? maxEnableDateTime,
required List<DateTime>? markDates}) {
/// 根据年份月份,生成日期,需要考虑闰年
final DateTime lastDay = DateTime(year, month + 1, 0);
final now = DateTime.now();
for (int i = 1; i <= lastDay.day; i++) {
final dateTime = DateTime(year, month, i);
bool isEnable = (minEnableDateTime == null ||
(dateTime.isAfter(minEnableDateTime) ||
(dateTime.year == minEnableDateTime.year &&
dateTime.month == minEnableDateTime.month &&
dateTime.day == minEnableDateTime.day))) &&
(maxEnableDateTime == null ||
dateTime.isBefore(maxEnableDateTime) ||
(dateTime.year == maxEnableDateTime.year &&
dateTime.month == maxEnableDateTime.month &&
dateTime.day == maxEnableDateTime.day));
_days.add(XBCalendarDay(
dateTime: dateTime,
isEnable: isEnable,
isToday: year == now.year && month == now.month && i == now.day,
isMark: isMark(dateTime, markDates)));
}
}