buildMonthDays method

Widget buildMonthDays(
  1. BuildContext context
)

Implementation

Widget buildMonthDays(BuildContext context) {
  final List<Row> dayRows = <Row>[];
  final List<DayNumber> dayRowChildren = <DayNumber>[];

  final int daysInMonth = getDaysInMonth(year, month);
  final int firstWeekdayOfMonth = DateTime(year, month, 1).weekday;

  for (int day = 2 - firstWeekdayOfMonth; day <= daysInMonth; day++) {
    Color color = Colors.transparent;
    if (day > 0) {
      color = getDayNumberColor(DateTime(year, month, day));
    }

    dayRowChildren.add(
      DayNumber(
        day: day,
        color: color,
      ),
    );

    if ((day - 1 + firstWeekdayOfMonth) % DateTime.daysPerWeek == 0 ||
        day == daysInMonth) {
      dayRows.add(
        Row(
          children: List<DayNumber>.from(dayRowChildren),
        ),
      );
      dayRowChildren.clear();
    }
  }

  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: dayRows,
  );
}