willExpireSoon method

bool willExpireSoon({
  1. Duration threshold = const Duration(minutes: 5),
})

Returns true if the token will expire within threshold.

Implementation

bool willExpireSoon({Duration threshold = const Duration(minutes: 5)}) {
  if (_currentToken == null || _currentToken!.expiresIn == null) return true;

  final expiresAt = _currentToken!.issuedAt.add(
    Duration(seconds: _currentToken!.expiresIn!),
  );
  final now = DateTime.now();
  return expiresAt.difference(now) <= threshold;
}