replacing method Null safety

TimeOfDay replacing(
  1. {int? hour,
  2. int? minute}
)

Returns a new TimeOfDay with the hour and/or minute replaced.

Implementation

TimeOfDay replacing({ int? hour, int? minute }) {
  assert(hour == null || (hour >= 0 && hour < hoursPerDay));
  assert(minute == null || (minute >= 0 && minute < minutesPerHour));
  return TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute);
}