saveTokens static method

Future<void> saveTokens({
  1. required String accessToken,
  2. String? refreshToken,
  3. String? deviceKey,
  4. String? idToken,
  5. String? email,
  6. String? userId,
})

Implementation

static Future<void> saveTokens({
  required String accessToken,
  String? refreshToken,
  String? deviceKey,
  String? idToken,
  String? email,
  String? userId,
}) async {
  await _storage.write(key: _accessTokenKey, value: accessToken);
  _memoryCache[_accessTokenKey] = accessToken;

  if (refreshToken != null) {
    debugPrint('refreshToken is not null, saving it $refreshToken');
    await _storage.write(key: _refreshTokenKey, value: refreshToken);
    _memoryCache[_refreshTokenKey] = refreshToken;
  }

  await _storage.write(key: _deviceKey, value: deviceKey);
  _memoryCache[_deviceKey] = deviceKey;

  if (idToken != null) {
    debugPrint('idToken is not null, saving it $idToken');
    await _storage.write(key: _idTokenKey, value: idToken);
    _memoryCache[_idTokenKey] = idToken;
  }
  if (email != null) {
    debugPrint('email is not null, saving it $email');
    await _storage.write(key: _emailKey, value: email);
    _memoryCache[_emailKey] = email;
  }
  if (userId != null) {
    debugPrint('userId is not null, saving it $userId');
    await _storage.write(key: _userIdKey, value: userId);
    _memoryCache[_userIdKey] = userId;
  }

}