isStaleIfError method

bool isStaleIfError([
  1. DateTime? now
])

Returns true if the entry is past TTL (and SWR) but still within the Stale-If-Error window.

Implementation

bool isStaleIfError([DateTime? now]) {
  final current = (now ?? DateTime.now().toUtc());
  final age = current.difference(createdAt);
  if (staleIfError == null) return false;
  final maxAllowedAge =
      ttl + (staleWhileRevalidate ?? Duration.zero) + staleIfError!;
  return age <= maxAllowedAge;
}