flutterdaterangepicker

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


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;
      }