apix library
Classes
- ApiClient
- A production-ready API client powered by Dio.
- ApiClientConfig
- Configuration for ApiClient.
- ApiClientFactory
- Factory for creating ApiClient instances.
- 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.
- CacheInterceptor
- Interceptor that provides response caching with configurable strategies.
- CacheStorage
- Abstract interface for cache storage backends.
- ErrorMapperInterceptor
-
Interceptor that transforms
DioExceptioninto 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.
- InMemoryCacheStorage
- In-memory implementation of CacheStorage.
- 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.
- MultipartInterceptor
- Interceptor that automatically handles multipart/form-data requests.
- RequestBreadcrumb
- Breadcrumb data for request tracking.
- RequestDeduplicator
- Deduplicates identical concurrent requests.
- RequestMetrics
- Request metrics data.
-
Result<
T, E extends ApiException> - A type that represents either a success value or a failure.
- RetryConfig
- Configuration for retry behavior.
- RetryInterceptor
- Interceptor that automatically retries failed requests.
- 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.
Enums
- BreadcrumbType
- Breadcrumb types.
- CacheStrategy
- Cache strategy options.
- LogLevel
- Log level for filtering log output.
Extensions
- CacheRequestExtension on RequestOptions
- Extension for per-request cache control.
- 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
- 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.
-
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.
-
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).
Exceptions / Errors
- ApiException
- Base exception class for all API-related errors.
- AuthException
- Exception thrown when authentication 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.
- 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.
- NetworkException
- Exception for network-related errors (connectivity, timeout).
- NotFoundException
- Exception thrown when a resource is not found (404 Not Found).
- ServerException
- Exception for server errors (5xx HTTP responses).
- TimeoutException
- Exception thrown when a request times out.
- Exception thrown when authentication is required (401 Unauthorized).