getDaysInBeteween static method

List<DateTime> getDaysInBeteween({
  1. required DateTime startDate,
  2. required DateTime endDate,
})

returns all dates from startDate - endDate in the form of List of DateTime

Implementation

static List<DateTime> getDaysInBeteween({
  required DateTime startDate,
  required DateTime endDate,
}) {
  List<DateTime> days = [];
  for (var i = 0; i <= (endDate.difference(startDate).inDays); i++) {
    days.add(
      DateTime(
        startDate.year,
        startDate.month,
        // In Dart you can set more than. 30 days, DateTime will do the trick
        startDate.day + i,
      ),
    );
  }
  return days;
}