Return all dates between two dates as a list in flutter date range picker

Issue

I got only two dates form flutter date_range_picker but I want a list of date between two selected dates. Thanks for your answers

Solution

Try the following :

List<DateTime> getDaysInBetween(DateTime startDate, DateTime endDate) {
    List<DateTime> days = [];
    for (int i = 0; i <= endDate.difference(startDate).inDays; i++) {
      days.add(startDate.add(Duration(days: i)));
    }
    return days;
  }

Answered By – Sukhi

Answer Checked By – Robin (AngularFixing Admin)

Leave a Reply

Your email address will not be published.