remainingLifetime method
Returns the time remaining until expiresAt.
Returns null when expiresAt is not set (unknown lifetime).
Returns Duration.zero when the token is already expired rather than
a negative duration, so callers can safely use it as a countdown.
Implementation
Duration? remainingLifetime([DateTime? now]) {
final exp = expiresAt;
if (exp == null) return null;
final remaining = exp.difference(now ?? DateTime.now());
return remaining.isNegative ? Duration.zero : remaining;
}