rest_client_builder library

Public API for the rest_client_builder package.

Exports annotations, core contracts (RestResult, RestError), and the Dio runtime (DioRestClient, RestPart, cancel/progress, interceptors).

Code generation is provided via build_runner builders — import this library in API/model sources, then run dart run build_runner build.

Implementation details under src/generator/ and src/internal/ are not part of the public API.

Classes

BaseUrl
Declares the default base URL for a REST client.
BasicCancelToken
Concrete CancelToken backed by Dio's cancel token.
BasicMultipartBody
Concrete multipart body.
BasicMultipartPart
Concrete multipart part.
BasicRestClientConfig
Minimal concrete RestClientConfig.
BasicRestRequest
Concrete RestRequest used by generated API clients.
BasicRestResponse
Concrete RestResponse used by adapters and tests.
Body
Binds a method parameter to the request body.
Cache
Enables response caching for an API method or class.
CallbackRestClient
Callback-driven RestClient for tests and local demos (no networking).
Cancel
Marks a parameter as the request cancellation token.
CancelToken
Token used to cancel an in-flight request.
ConnectTimeout
Declares the connection timeout.
ConsoleRestLogger
RestLogger that writes to the console via print.
DefaultInterceptorPipeline
Default InterceptorPipeline with forward request / reverse response order.
DELETE
HTTP DELETE request.
DioErrorMapper
Maps Dio failures into transport-agnostic RestError values.
DioRestClient
Dio-powered RestClient with global config, retry, timeouts, logging, headers, and interceptor resolution.
DioRestHttpEngine
Dio-backed RestHttpEngine.
EnableLog
Enables request/response logging for a client or method.
ExcludeInterceptor
Excludes interceptors that would otherwise apply.
Failure<T>
Failed RestResult carrying a RestError.
Field
Binds a method parameter to a form field.
FieldMap
Binds a Map parameter as multiple form fields.
FormUrlEncoded
Marks a method as an application/x-www-form-urlencoded request.
GET
HTTP GET request.
GlobalInterceptors
Registers interceptors applied to every request of a client.
HTTP HEAD request.
Binds a method parameter to a single request header.
HeaderMap
Binds a Map parameter as multiple request headers.
Headers
Declares static HTTP headers for a client or method.
HTTP
Generic HTTP method annotation for custom or non-standard verbs.
HttpHeaderNames
Common HTTP header name constants.
HttpMethod
Base type for HTTP verb annotations.
HttpMethodNames
Canonical HTTP method name constants.
HttpStatusCodes
Common HTTP status code constants.
InterceptorPipeline
Orchestrates a list of RestInterceptors around an HTTP send operation.
JsonKey
An annotation used to specify how a field is serialized.
JsonUtils
JSON encode/decode helpers that return RestResult on failure.
LoggingRestInterceptor
Logs request / response / error lines when attached to a pipeline.
MapUtils
Map helpers for headers, query maps, and JSON-like structures.
Multipart
Marks a method as a multipart/form-data request.
NoOpRestLogger
RestLogger that discards all messages.
OPTIONS
HTTP OPTIONS request.
Part
Binds a method parameter to a multipart form part.
PartMap
Binds a Map parameter as multiple multipart parts.
PATCH
HTTP PATCH request.
Path
Binds a method parameter to a path placeholder ({name}).
POST
HTTP POST request.
PUT
HTTP PUT request.
Query
Binds a method parameter to a single query parameter.
QueryMap
Binds a Map parameter as multiple query parameters.
QueuedItem
A single queued request item held in RestRequestQueue.
ReceiveTimeout
Declares the receive timeout.
ResilientQueue
Marks an abstract REST API method for automatic resilient request queueing.
RestApi
Marks an abstract class as a REST API client definition.
RestApiClientRegistry
Process-wide cache of RestClients keyed by configuration Type.
RestApiGlobalConfiguration
Contract for application-wide REST settings.
RestClient
High-level REST client entry point used by generated and handwritten APIs.
RestClientBuilder
Builder pattern for creating a RestClient without exposing Dio directly.
RestClientConfig
Runtime configuration for a RestClient.
RestConfiguration
Marks a class as the REST client configuration root.
RestConstants
Common string constants used across the framework.
RestErrorCodes
Well-known RestError.code values used by factory constructors.
RestExecutionExtras
Per-request overrides emitted from API and endpoint annotations.
RestExecutionOptions
Resolved annotation values for one request.
RestGlobalConfig
Standard application-wide REST settings.
RestHttpEngine
Low-level HTTP transport abstraction.
RestInterceptor
Intercepts requests and responses in the runtime pipeline.
RestInterceptorExtras
Keys written into RestRequest.extras by generated clients.
RestKey
Declares multiple JSON key aliases for a field on an @RestModel class.
RestLogger
Abstract logger contract used by core and future runtime layers.
RestModel
Marks a class as a REST data model eligible for (de)serialization helpers.
RestMultipartBody
Multipart request body composed of parts.
RestMultipartPart
A single part in a multipart request.
RestPart
Binary multipart part that never depends on dart:io File APIs.
RestProgressListener
Optional object-oriented progress listener.
RestQueueFlushResult
Result summary returned by RestRequestQueue.flush.
RestQueueInterceptor
Interceptor that automatically enqueues failed requests into a RestRequestQueue.
RestQueueResolver
Strategy interface for deciding whether a queued request should be removed from RestRequestQueue after replay.
RestRequest
Immutable view of an outgoing HTTP request.
RestRequestQueue
An in-memory queue for offline & resilient request queueing.
RestResponse
Immutable view of an HTTP response.
RestResponseCache
Process-wide in-memory response cache for @Cache annotated endpoints.
RestResponseMapper
Maps raw RestClient.execute results into typed RestResults.
RestResult<T>
A discriminated result representing either a Success or a Failure.
Retry
Declares automatic retry policy for a client or method.
SendTimeout
Declares the send timeout.
SSE
Marks an abstract REST API method as a Server-Sent Events (SSE) endpoint.
SSEEvent
A single event received over a Server-Sent Events (SSE) connection.
SseParser
Stateful SSE text-frame parser.
Streaming
Marks a REST method to stream the response body instead of buffering it.
StringUtils
String helpers shared by core and future runtime layers.
Success<T>
Successful RestResult carrying data.
Tag
Groups API methods under an OpenAPI-style tag.
TypeUtils
Lightweight type helpers for diagnostics and safe casting.
Url
Replaces the full request URL with the annotated parameter value.
UseInterceptor
Applies additional interceptors to a client or method.
ValidationUtils
Validation helpers that return RestResult instead of throwing.

Enums

RestBodyType
Classification of a RestRequest body.
RestLogLevel
Severity levels for RestLogger.

Constants

restApiBuilderPackage → const String
Package identity used for smoke tests and diagnostics.
streaming → const Streaming
Convenience constant for @Streaming().

Functions

joinRestUrl(String baseUrl, String path) String
Joins baseUrl and path, normalizing slashes.
readRestExecutionOptions(Map<String, Object?> extras) RestExecutionOptions
Reads execution options from request extras.
readRestInterceptorExtras(Map<String, Object?> extras) → ({List<String> exclude, List<String> use})
Reads interceptor type-name lists from request extras.
resolveRestInterceptors({required List<RestInterceptor> global, List<RestInterceptor> perRequest = const <RestInterceptor>[], List<String> useTypeNames = const <String>[], List<String> excludeTypeNames = const <String>[]}) List<RestInterceptor>
Resolves the effective interceptor list for a call.
resolveRestPath(String template, Map<String, String> pathParams) String
Replaces {name} path placeholders with encoded values.
restInterceptorTypeName(RestInterceptor interceptor) String
Runtime type name used for @UseInterceptor / @ExcludeInterceptor matching.
stringifyRestValue(Object? value) String
Converts a value into a query/header string.

Typedefs

Interceptor = RestInterceptor
Short name for RestInterceptor, intended for configuration declarations.
OfflineQueue = ResilientQueue
Backward compatible alias for ResilientQueue.
RestProgressCallback = void Function(int count, int total)
Reports transfer progress for uploads or downloads.

Exceptions / Errors

RestError
A structured, transport-agnostic error used by Failure and core helpers.