setToken method

Future<void> setToken(
  1. T? token
)

Sets the internal token to the provided token and updates the AuthenticationStatus accordingly.

If the provided token is null, the AuthenticationStatus will be updated to unauthenticated and the token will be removed from storage, otherwise it will be updated to authenticatedand save to storage.

Implementation

Future<void> setToken(T? token) async {
  if (token == null) return clearToken();
  await _tokenStorage.write(token);
  _updateStatus(token);
}