nextDay method

DateTime nextDay({
  1. bool startOfDay = true,
})

Returns the next day.

This method calculates the day after the current DateTime object. It handles month and year changes correctly. startOfDay if true, returns the next day at 00:00:00.

Implementation

DateTime nextDay({bool startOfDay = true}) {
  DateTime result = add(const Duration(days: 1));
  if (startOfDay) {
    result = DateTime(result.year, result.month, result.day);
  }
  return result;
}