isRefreshTokenExpired property

bool get isRefreshTokenExpired

Whether the refresh token has expired or is within 5 minutes of expiry.

When this returns true, both the access token and refresh token are effectively expired and the user must log in again.

if (token.isRefreshTokenExpired) {
  await authService.logout();
}

Implementation

bool get isRefreshTokenExpired {
  final DateTime expirationDateTime = DateTime.fromMillisecondsSinceEpoch(refreshExpiresIn, isUtc: true);

  final DateTime expirationWithBuffer = expirationDateTime.subtract(expiryBuffer);

  return !DateTime.now().toUtc().isBefore(expirationWithBuffer);
}