copyWith method

  1. @useResult
Period copyWith({
  1. int? years,
  2. int? months,
  3. int? days,
  4. int? hours,
  5. int? minutes,
  6. int? seconds,
  7. int? milliseconds,
  8. int? microseconds,
})

Creates a copy of this with the updated units of time.

No normalization is performed.

Period(years: 1, months: 1).copyWith(months: 13); // 1 year 13 months

Implementation

@useResult Period copyWith({
  int? years,
  int? months,
  int? days,
  int? hours,
  int? minutes,
  int? seconds,
  int? milliseconds,
  int? microseconds,
}) => Period(
  years: years ?? this.years,
  months: months ?? this.months,
  days: days ?? this.days,
  hours: hours ?? this.hours,
  minutes: minutes ?? this.minutes,
  seconds: seconds ?? this.seconds,
  milliseconds: milliseconds ?? this.milliseconds,
  microseconds: microseconds ?? this.microseconds,
);