nextDay method

  1. @useResult
DateTime nextDay({
  1. bool isStartOfDay = true,
})

Returns the next day.

This method calculates the day after the current DateTime object. It handles month and year changes correctly. isStartOfDay if true, returns the next day at 00:00:00. If false, keeps this value's wall-clock time on the next calendar day (not exactly 24 elapsed hours later, which differs across DST).

The result keeps this value's kind: a UTC input yields UTC (midnight UTC when isStartOfDay is true), a local input yields local.

Example:

DateTime.utc(2026, 3, 7, 15).nextDay(); // 2026-03-08 00:00Z

Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
DateTime nextDay({bool isStartOfDay = true}) {
  // Bug fix: a 24h Duration step from midnight on a 25-hour DST day landed at
  // 23:00 the same day, returning the input date. Step by calendar day.
  final DateTime result = addCalendarDays(1);

  // Truncate in the input's kind so a UTC value does not come back local.
  return isStartOfDay ? result.startOfDayInKind : result;
}