getYearsInBeteween static method

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

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

Implementation

static List<DateTime> getYearsInBeteween({
  required DateTime startDate,
  required DateTime endDate,
}) {
  List<DateTime> years = [];
  for (int i = startDate.year; i <= endDate.year; i++) {
    years.add(DateTime(i));
  }
  return years;
}