willExpireWithin method

bool willExpireWithin(
  1. Duration duration, [
  2. DateTime? now
])

Returns true if the token will expire within duration from now.

Implementation

bool willExpireWithin(Duration duration, [DateTime? now]) {
  final exp = expiresAt;
  if (exp == null) return false;
  final n = now ?? DateTime.now();
  final threshold = n.add(duration);
  return !threshold.isBefore(exp);
}