daysUntil method
Returns the number of calendar days between this date and other.
The result is positive when other is after this date, negative when
before. Only the date portion is considered (time is ignored).
DateTime(2025, 6, 10).daysUntil(DateTime(2025, 6, 15)); // 5
DateTime(2025, 6, 15).daysUntil(DateTime(2025, 6, 10)); // -5
Implementation
int daysUntil(DateTime other) {
final a = DateTime(year, month, day);
final b = DateTime(other.year, other.month, other.day);
return b.difference(a).inDays;
}