addYears method

DateTime addYears(
  1. int years
)

Add years to this DateTime

Example:

final date = DateTime(2023, 12, 25);
print(date.addYears(2)); // 2025-12-25

Implementation

DateTime addYears(int years) => DateTime(
  year + years,
  month,
  day,
  hour,
  minute,
  second,
  millisecond,
  microsecond,
);