adapters/http_client_adapter library

Classes

HTTPClientAdapter
High-level HTTP client shared across the Flutter SDK.
HttpClientResponse
Minimal response container, platform-agnostic.

Functions

buildAuthHeaders({required String apiKey, String? accessToken}) Map<String, String>
Split-header auth overlay, FFI-free so it can be unit-tested without a native library: apikey always travels independently of Authorization, and Authorization: Bearer carries only a JWT access token. A missing token omits the header entirely rather than falling back to the API key (matches Kotlin's HTTPClientAdapter.buildHeaders) — collapsing the two turns a missing/expired-token failure into the backend's misleading "Invalid JWT token: Not enough segments".
resolveAccessToken({required bool requiresAuth, String? cachedAccessToken, Future<String?> tokenResolver({required bool requiresAuth})?, void onResolverError(Object error)?}) Future<String?>
Resolve the bearer token for a request. Requests that do not require auth never attempt token resolution and never send Authorization. Exposed for testing — pure aside from the injected tokenResolver callback, so the API-key-only / JWT-only / keyless / expired-token / resolver-failure matrix can be characterized without FFI.

Exceptions / Errors

HttpClientException
Thrown when the underlying libcurl call fails before we have a server status (DNS, TLS, connect, cancel, etc.) or when the caller has not configured the adapter yet.