logoutWithRequest method

  1. @override
Future<InappifySdkResult<void>> logoutWithRequest(
  1. InappifyNetworkRequest request
)
inherited

Cancellation-aware logout used by browser backends.

Existing adapters inherit the legacy logout behavior. Implementations that accept request cancellation may override this additive method.

Implementation

@override
Future<InappifySdkResult<void>> logoutWithRequest(
  InappifyNetworkRequest request,
) async {
  final cancelled = _preCancelled<void>('logout', request.cancellation);
  if (cancelled != null) return cancelled;
  return _run<void>(
    'logout',
    action: () async {
      final previousCustomer = _customerInfo;
      final previousOfferings = _offerings;
      await _callSessionMutation(
        method: 'logout',
        positionalArguments: request.cancellation == null
            ? const <Object?>[]
            : const <Object?>[<String, Object?>{}],
        cancellation: request.cancellation,
        injectAbortSignal: request.cancellation != null,
        previousCustomer: previousCustomer,
        previousOfferings: previousOfferings,
      );
      _clearUnchangedSessionMirrors(previousCustomer, previousOfferings);
      _bridge.clearPendingCheckout();
      await _refreshCachedStateBestEffort(includeOfferings: true);
    },
    cancellation: request.cancellation,
    mutationMayHaveCommitted: true,
  );
}