isWithinLastDays method

  1. @useResult
bool isWithinLastDays(
  1. int n,
  2. DateTime now
)

True if this is on or after now minus n days and not after now.

Implementation

@useResult
bool isWithinLastDays(int n, DateTime now) {
  final DateTime cutoff = DateTime(now.year, now.month, now.day - n);
  return !isBefore(cutoff) && !isAfter(now);
}