addMonths method

DateTime addMonths(
  1. int months
)

Returns date as the first day of the next month

Implementation

DateTime addMonths(int months) {
  final finalMonth = month + months;

  return DateTime(
    year + (finalMonth > 12 ? finalMonth ~/ 12 : 0),
    finalMonth > 12 ? finalMonth % 12 : finalMonth,
  );
}