BloomHttpClient class

HTTP client with environment base URL resolution, JSON codecs, Bearer auth token injection, DevTools tracing, and simulation hooks.

Resolves relative endpoints against API_BASE_URL or configured baseUrl, attaches authorization bearer tokens, tracks network requests in DevTools inspector, and reports telemetry breadcrumbs to BloomObservability.

Example:

final client = BloomHttpClient(
  baseUrl: 'https://api.example.com',
  authTokenProvider: () => authSession.token.value,
);
final user = await client.get<Map<String, dynamic>>('/users/me');

Constructors

BloomHttpClient({String? baseUrl, Client? innerClient, Duration timeout = const Duration(seconds: 15), String? authToken, String? authTokenProvider()?})
Creates a BloomHttpClient configured with an optional baseUrl, timeout, and auth tokens.

Properties

authToken String?
Static bearer token attached to outgoing Authorization: Bearer <token> headers.
getter/setter pair
authTokenProvider String? Function()?
Dynamic provider callback resolving bearer tokens at request dispatch time.
getter/setter pair
baseUrl String?
Base URL prefix prepended to relative request paths (e.g. 'https://api.example.com').
final
hashCode int
The hash code for this object.
no setterinherited
requestInterceptors List<RequestInterceptor>
Ordered list of interceptors executed prior to dispatching requests.
final
responseInterceptors List<ResponseInterceptor>
Ordered list of interceptors executed upon receiving responses.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
Network timeout duration applied to requests (defaults to 15 seconds).
final

Methods

close() → void
Closes the underlying HTTP client and releases network sockets.
delete<T>(String path, {dynamic body, Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<T>
Sends an HTTP DELETE request to path with optional body and decodes the JSON response as T.
get<T>(String path, {Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<T>
Sends an HTTP GET request to path and decodes the JSON response as T.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch<T>(String path, {dynamic body, Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<T>
Sends an HTTP PATCH request to path with optional body and decodes the JSON response as T.
post<T>(String path, {dynamic body, Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<T>
Sends an HTTP POST request to path with optional body and decodes the JSON response as T.
put<T>(String path, {dynamic body, Map<String, String>? headers, Map<String, dynamic>? queryParameters}) Future<T>
Sends an HTTP PUT request to path with optional body and decodes the JSON response as T.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited