nextMonth property

DateTime get nextMonth

Returns the next month for the current DateTime instance.

Example usage:

final date = DateTime(2020, 11, 15);
final nextMonth = date.nextMonth;
print(nextMonth); // 2020-12-15 00:00:00.000

Implementation

DateTime get nextMonth {
  var year = this.year;
  var month = this.month;

  if (month == 12) {
    year++;
    month = 1;
  } else {
    month++;
  }
  return DateTime(year, month, day, hour, minute, second, millisecond, microsecond);
}