tomorrow static method

  1. @useResult
DateTime tomorrow({
  1. DateTime? now,
  2. int? hour,
  3. int minute = 0,
  4. int second = 0,
})

Returns the date for tomorrow at the specified time.

Pass now to override the current date (useful for testing). The returned date has its time set to hour, minute, and second (all defaulting to 0).

Implementation

@useResult
static DateTime tomorrow({DateTime? now, int? hour, int minute = 0, int second = 0}) {
  // Calculate the date for tomorrow at the specified time
  final DateTime resolvedNow = now ?? DateTime.now();
  final DateTime tomorrowAtSpecifiedTime = resolvedNow.addDays(1);

  return tomorrowAtSpecifiedTime.copyWith(
    hour: hour ?? 0,
    minute: minute,
    second: second,
    microsecond: 0,
  );
}