copyWith method

DateTime copyWith({
  1. int? year,
  2. int? month,
  3. int? day,
  4. int? hour,
  5. int? minute,
  6. int? second,
})

Creates a new DateTime by copying this one and overriding given fields.

Implementation

DateTime copyWith({
  int? year,
  int? month,
  int? day,
  int? hour,
  int? minute,
  int? second,
}) {
  return DateTime(
    year ?? this.year,
    month ?? this.month,
    day ?? this.day,
    hour ?? this.hour,
    minute ?? this.minute,
    second ?? this.second,
  );
}