flutter_client_factory library
HTTP models, middleware contracts, client factories and platform HTTP transport.
Classes
- BufferedHttpResponse
- A defensive byte snapshot that can create independently consumable responses.
- ByteRequestBody
- A defensive copy of bytes that can be sent more than once.
- CancellationToken
- Cancelable operations subscribe with onCancel and remove their listener.
- ClientRegistration
- An options snapshot and builder for independently owned shared transports.
-
ContextKey<
T> - An identity-based key for metadata that is never sent over the network.
- DefaultHttpClientFactory
- Creates lightweight named clients over rotating, response-aware transport leases. Owns all transports built by registrations; close the factory at scope end.
- DownloadProgressEvent
- Cumulative response bytes delivered during one transport attempt.
- FormData
- Multipart form fields and file/stream parts using the existing streaming encoder. For repeated field names, supply MultipartPart.text entries in parts.
- FormRequestBody
- Replayable UTF-8 application/x-www-form-urlencoded fields.
- HttpClient
- HttpClientFactory
- HttpClientOptions
- A snapshot of logical client configuration.
- HttpClientRegistrationBuilder
- Mutable registration configuration, copied into an immutable snapshot by build. Does not create a transport or send requests.
- HttpClientService
- Applies client options and middleware to a borrowed transport.
- HttpDefaults
- Shared protocol defaults, not example application configuration.
- HttpEvent
- Base event emitted by the optional client observer for each transport attempt.
- HttpHeaders
- Immutable, case-insensitive names with separate values preserved.
- HttpMiddleware
- HttpRequest
- Immutable HTTP input. Copying retains the body and its replayability contract.
- HttpResponse
- HTTP status, headers and a single-consumption response body. Always consume the body or await dispose, including for unsuccessful statuses.
- HttpTransport
- Owns network I/O, connections, and cancellation of request/body streams.
- JsonRequestBody
- Serializes once so caller mutations cannot change a later retry.
- MultipartPart
- One named multipart field with an optional file name and content headers.
- MultipartRequestBody
- Streaming multipart/form-data with a generated boundary. Replayability and known content length depend on every part.
- RequestBody
- An encoded body. Retrying middleware must check isReplayable.
- RequestContext
- Immutable request options. Mutable attempt state belongs to middleware.
- RequestSentEvent
- A transport attempt is about to start.
- ResponseBodyReader
- Consumes and disposes a response with a configurable buffering limit. Text decoding is UTF-8; JSON decoding requires an explicit domain converter.
- ResponseCompletedEvent
- A response body was fully consumed; cancellation does not emit completion.
- ResponseHeadersEvent
- A transport attempt has received its HTTP status and response headers.
- StreamRequestBody
- Caller-supplied upload stream with explicit replayability. The default constructor permits one read; a replay factory must produce equivalent bytes.
- TextRequestBody
- UploadProgressEvent
- Cumulative bytes handed to one transport attempt, not peer acknowledgment.
Enums
Extensions
- HttpClientFactoryRegistration on HttpClientFactory
- Convenience registration for any implementation of HttpClientFactory.
- HttpClientRequests on HttpClient
- String-URL convenience methods over the same send pipeline. Raw responses retain all HTTP statuses and must be consumed or disposed.
- HttpRequestExtensions on HttpRequest
- Immutable request transformations that preserve body, context, and timeout.
- HttpResponseExtensions on HttpResponse
- Bounded body reading and explicit response ownership conveniences.
Functions
Typedefs
-
HttpInterceptor
= Future<
HttpResponse> Function(HttpRequest request, CancellationToken cancellationToken, HttpRequestHandler next) -
Middleware may return a response without forwarding to
next. Callingnextagain repeats only the interceptors later in the list. Consume or dispose a discarded response before resending, and only resend requests whose method and body are safe to replay. -
HttpRequestHandler
= Future<
HttpResponse> Function(HttpRequest request, CancellationToken cancellationToken) - HttpTransportBuilder = HttpTransport Function()
- Must create a new, independently owned transport for each registration.
Exceptions / Errors
- HttpStatusException
- An explicitly rejected HTTP status, without buffering an error body.
- NetworkException
- RequestCanceledException
- A request canceled by its caller, distinct from a timeout.
- RequestTimeoutException