isWithinLastHours method

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

True if this is within the last n hours before now.

Implementation

@useResult
bool isWithinLastHours(int n, DateTime now) {
  final DateTime cutoff = now.subtract(Duration(hours: n));
  return !isBefore(cutoff) && !isAfter(now);
}