ensureNotSoftLoggedOut method
Checks if the token expires in under expiresIn
time and calls the
given onSoftLogout()
if so. You have to provide onSoftLogout
in the
Client constructor. Otherwise this will do nothing.
Implementation
Future<void> ensureNotSoftLoggedOut(
[Duration expiresIn = const Duration(minutes: 1)]) async {
final tokenExpiresAt = accessTokenExpiresAt;
if (onSoftLogout != null &&
tokenExpiresAt != null &&
tokenExpiresAt.difference(DateTime.now()) <= expiresIn) {
await _handleSoftLogout();
}
}