generateDays static method

List<List<DateTime>> generateDays(
  1. DateTime? date
)

Implementation

static List<List<DateTime>> generateDays(DateTime? date) {
  final output = List.generate(5, (index) => <DateTime>[], growable: false);
  if (date == null) {
    return output;
  }
  var iDate = DateTime(date.year, date.month, 1);

  // Set first date to monday
  iDate = iDate.subtract(Duration(days: iDate.weekday - 1));
  for (var w = 0; w < 5; w++) {
    for (var d = 0; d < 7; d++) {
      output[w].add(iDate);
      iDate = DateTime(iDate.year, iDate.month, iDate.day + 1);
    }
  }

  return output;
}