addMonths method

DateTime addMonths(
  1. int amount
)

Adds a specified number of months to the current DateTime instance.

Example usage:

final date = DateTime(2020, 1, 1);
final newDate = date.addMonths(2);
print(newDate); // 2020-03-01 00:00:00.000

Implementation

DateTime addMonths(int amount) => DateTime(year, month + amount, day, hour, minute, second);