apix library
Classes
- ApiClient
- A production-ready API client powered by Dio.
- ApiClientConfig
- Configuration for ApiClient.
- ApiClientFactory
- Factory for creating ApiClient instances.
- ApiSpan
- A performance span opened for a single request.
- AuthConfig
- Configuration for authentication handling.
- AuthInterceptor
- Interceptor that automatically adds authentication headers to requests and handles token refresh on configured status codes.
- CacheConfig
- Configuration for cache behavior.
- CacheControlHeader
- Parsed Cache-Control header directives.
- CacheEntry
- A cached response entry with metadata.
- CacheFailure
- A storage failure the cache absorbed.
- CacheHit
- A response served from storage rather than from the network.
- CacheInterceptor
- Interceptor that provides response caching with configurable strategies.
- CacheStorage
- Abstract interface for cache storage backends.
- CancelToken
- Controls cancellation of Dio's requests.
- DeduplicationConfig
- Configuration for standalone request deduplication.
- DeduplicationInterceptor
- Interceptor that collapses identical concurrent requests into one call, without storing anything.
- EncryptedCacheStorage
- Wraps any CacheStorage so response bodies are encrypted at rest.
- ErrorInterceptorHandler
- The handler for interceptors to handle error occurred during the request.
- ErrorMapperInterceptor
- Interceptor that transforms DioException into typed ApiException.
- ErrorTrackingConfig
- Configuration for the error tracking interceptor.
- ErrorTrackingInterceptor
- Interceptor that captures API errors to error tracking services.
-
Failure<
T, E extends ApiException> - A failed result containing an error.
- FileCacheStorage
- A CacheStorage that survives process restarts by writing one JSON file per entry.
- FormData
- A class to create readable "multipart/form-data" streams. It can be used to submit forms and file uploads to http server.
- Headers
- The headers class for requests and responses.
- InMemoryCacheStorage
- In-memory implementation of CacheStorage.
- Interceptor
- Interceptor helps to deal with RequestOptions, Response, and DioException during the lifecycle of a request before it reaches users.
- LogEntry
- Structured log entry for request/response logging.
- LoggerConfig
- Configuration for the logger interceptor.
- LoggerInterceptor
- Interceptor that logs HTTP requests and responses.
- MetricsConfig
- Configuration for the metrics interceptor.
- MetricsInterceptor
- Interceptor that tracks request metrics and breadcrumbs.
- MultipartFile
-
An upload content that is a part of
MultipartRequest. This doesn't need to correspond to a physical file. - MultipartInterceptor
- Interceptor that automatically handles multipart/form-data requests.
- Options
- The configuration for a single request. BaseOptions and Options will be merged into one RequestOptions before sending the requests. See Options.compose.
- RequestBreadcrumb
- Breadcrumb data for request tracking.
- RequestDeduplicator
- Deduplicates identical concurrent requests.
- RequestInterceptorHandler
- The handler for interceptors to handle before the request has been sent.
- RequestMetrics
- Request metrics data.
- RequestOptions
- The internal request option class that is the eventual result after BaseOptions and Options are composed.
-
Response<
T> - The Response class contains the payload (could be transformed) that respond from the request, and other information of the response.
- ResponseInterceptorHandler
- The handler for interceptors to handle after respond.
- ResponseValidatorInterceptor
- Interceptor that runs a ResponseValidator on every 2xx response.
-
Result<
T, E extends ApiException> - A type that represents either a success value or a failure.
- RetryAttempt
-
A retry about to be scheduled, handed to
RetryInterceptor.onRetry. - RetryConfig
- Configuration for retry behavior.
- RetryInterceptor
- Interceptor that automatically retries failed requests.
- SecureStorageRecovery
- A deletion SecureStorageService is about to perform to recover from data it cannot decrypt.
- SecureStorageService
-
A wrapper service for
FlutterSecureStorageproviding simplified secure key-value storage operations. - SecureTokenProvider
- A ready-to-use TokenProvider implementation using SecureStorageService.
- SentrySetup
- Sentry setup and initialization helper.
- SentrySetupOptions
- Configuration options for Sentry initialization.
-
Success<
T, E extends ApiException> - A successful result containing a value.
- TokenProvider
- Interface for providing authentication tokens.
- TracingConfig
- Configuration for TracingInterceptor.
- TracingInterceptor
- Interceptor that opens one performance span per network request.
Enums
- BreadcrumbType
- Breadcrumb types.
- CacheBodyEncoding
- How a response body was turned into the CacheEntry.data string, and therefore how it must be turned back.
- CacheOperation
- What the cache was doing when the storage backend refused.
- CacheStrategy
- Cache strategy options.
- DioExceptionType
- The exception enumeration indicates what type of exception has happened during requests.
- LogLevel
- Log level for filtering log output.
- ResponseType
- Indicates which transformation should be applied to the response data.
- SecureStorageOperation
- Which read triggered a recovery deletion.
- TokenProviderOperation
- The kind of operation a TokenProviderException is reporting on.
Extensions
- CacheRequestExtension on RequestOptions
- Extension for per-request cache control.
- CacheResponseExtension on Response
- Provenance of a response: cache or network, fresh or stale.
- LoggerRequestExtension on RequestOptions
- Extension to attach timing data to requests.
- LogLevelExtension on LogLevel
- Extension to add emoji prefixes to log levels.
- NoRetryExtension on RequestOptions
- Extension to easily mark requests as non-retryable.
-
ResultExtension
on Future<
T> - Extension to convert a Future to a Result.
Constants
- forceRetryKey → const String
- Key used to force retry of a request whose method is not in RetryConfig.retryableMethods (e.g. an idempotency-key-protected POST).
- forceRevalidateKey → const String
-
Key set on
RequestOptions.extrato force a conditional revalidation. - fromCacheKey → const String
-
Key set on
Response.extrawhen the body came from the cache. - fromCacheStaleKey → const String
-
Key set on
Response.extrawhen the cached body served had expired. - noRetryKey → const String
- Key used to mark a request as non-retryable.
Typedefs
-
AddBreadcrumb
= void Function(Map<
String, dynamic> data) - Signature for adding breadcrumbs to an error tracking service.
- BreadcrumbHandler = void Function(RequestBreadcrumb breadcrumb)
- Signature for breadcrumb handler.
- CacheCipher = String Function(String value)
- Transforms a string one way and back — supplied by the caller.
- CacheErrorHandler = void Function(CacheFailure failure)
- Signature for CacheConfig.onCacheError.
- CacheHitHandler = void Function(CacheHit hit)
- Signature for CacheConfig.onCacheHit.
-
CaptureException
= Future<
void> Function(Object exception, {Map<String, dynamic> ? extra, StackTrace? stackTrace, Map<String, String> ? tags}) - Signature for capturing exceptions to an error tracking service.
- LogHandler = void Function(LogEntry entry)
- Signature for custom log handlers.
- MetricsHandler = void Function(RequestMetrics metrics)
- Signature for metrics handler.
-
OnAuthFailureCallback
= Future<
void> Function(TokenProvider tokenProvider, Object? error) - Callback invoked when token refresh fails.
-
OnTokenRefreshedCallback
= Future<
void> Function(Response response) - Callback invoked after successful token refresh with raw response.
-
RefreshCallback
= Future<
bool> Function(TokenProvider tokenProvider) - Callback for refreshing tokens (legacy approach).
- ResponseValidator = ApiException? Function(Response response)
-
A callback that inspects a successful (2xx) response and either returns
nullto let it pass through, or returns an ApiException subclass to have the request fail with that exception. - SpanStarter = ApiSpan? Function(String operation, String description)
- Opens a span for a request. Returning null means "don't trace this one".
Exceptions / Errors
- ApiException
- Base exception class for all API-related errors.
- AuthException
- Exception thrown when token refresh fails.
- CacheException
- Exception thrown when cache operations fail.
- ClientException
- Exception for client errors (4xx HTTP responses).
- ConnectionException
- Exception thrown when a connection cannot be established.
- DioException
- DioException describes the exception info when a request failed.
- ForbiddenException
- Exception thrown when access is forbidden (403 Forbidden).
- HttpException
- Exception for HTTP-related errors (4xx, 5xx responses).
- HttpTrackingException
- Exception representing an HTTP error captured by error tracking.
- MultipartReplayException
- Thrown when a multipart request has to be sent a second time and apix cannot rebuild its body.
- NetworkException
- Exception for network-related errors (connectivity, timeout).
- NotFoundException
- Exception thrown when a resource is not found (404 Not Found).
- ParsingException
- Exception thrown when a response body cannot be parsed.
- ServerException
- Exception for server errors (5xx HTTP responses).
- TimeoutException
- Exception thrown when a request times out.
- TokenProviderException
- Exception thrown when a TokenProvider operation fails.
- TooManyRequestsException
- Exception thrown when the client is rate limited (429 Too Many Requests).
- Exception thrown when authentication is required (401 Unauthorized).
- UnexpectedContentTypeException
-
Exception thrown when a typed-decode method receives a response whose
Content-Typeheader does not match the expected media type.