diffInDays static method

int diffInDays({
  1. required DateTime to,
  2. DateTime? from,
})

Returns the absolute value of the difference in days between two dates. The difference is calculated by comparing only the year, month, and day values of the dates. The hour, minute, second, and millisecond values are ignored. For example, if date1 is August 22nd at 11 p.m. and date2 is August 24th at 12 a.m. midnight, the difference in days is 2, not a fraction of a day.

Implementation

static int diffInDays({required DateTime to, DateTime? from}) =>
    to.daysDifferenceTo(from);