signOut method

Future<AuthResponse<void>> signOut({
  1. Map<String, String>? fetchOptions,
})

Signs out the current user.

This clears the stored token and updates the session state. Optionally accepts fetchOptions for custom fetch configuration.

Example:

await authClient.signOut();

Implementation

Future<AuthResponse<void>> signOut({
  Map<String, String>? fetchOptions,
}) async {
  try {
    await _dio.post(
      ApiEndpoints.signOut,
      data: fetchOptions,
    );
    await _storage.delete(StorageKeys.accessToken);
    _sessionNotifier.value = null;
    return AuthResponse.success(null);
  } on DioException catch (e) {
    // Clear session even on error
    await _storage.delete(StorageKeys.accessToken);
    _sessionNotifier.value = null;
    return AuthResponse.error(AuthError.fromDio(e));
  }
}