getMonthDifference static method

int getMonthDifference({
  1. required DateTime startDate,
  2. required DateTime endDate,
})

Calculates the difference in months between two dates.

Implementation

static int getMonthDifference({
  required DateTime startDate,
  required DateTime endDate,
}) {
  final monthsDifference =
      (endDate.year - startDate.year) * 12 + endDate.month - startDate.month;
  return monthsDifference.abs();
}