copyWith static method

DateTime copyWith(
  1. DateTime date, {
  2. int? year,
  3. int? month,
  4. int? day,
  5. int? hour,
  6. int? minute,
  7. int? second,
  8. int? millisecond,
  9. int? microsecond,
})

Creates a copy of date but with the given fields replaced with the new values.

Implementation

static DateTime copyWith(DateTime date,
        {int? year,
        int? month,
        int? day,
        int? hour,
        int? minute,
        int? second,
        int? millisecond,
        int? microsecond}) =>
    _date(
        date.isUtc,
        year ?? date.year,
        month ?? date.month,
        day ?? date.day,
        hour ?? date.hour,
        minute ?? date.minute,
        second ?? date.second,
        millisecond ?? date.millisecond,
        microsecond ?? date.microsecond);