RetryInterceptor class
Smart retry interceptor with exponential backoff and idempotency guard
Features:
- Exponential backoff with configurable delays
- Idempotency protection (prevents retrying non-idempotent methods by default)
- Configurable retry conditions
- Request-level retry override
- Automatic retry count tracking
Safety:
- GET, HEAD, PUT, DELETE, OPTIONS, TRACE are retried by default
- POST, PATCH require explicit opt-in via extra
'allowRetry'= true
IMPORTANT: Requires DioProvider injection to maintain interceptors
Example:
// Default configuration
final retryInterceptor = RetryInterceptor();
// Custom configuration
final retryInterceptor = RetryInterceptor(
dioProvider: KeystoneNetwork.dioProvider, // ✅ Pass provider
config: RetryConfig(maxAttempts: 5),
);
KeystoneNetwork.initialize(
baseUrl: 'https://api.example.com',
interceptors: [retryInterceptor],
);
- Inheritance
-
- Object
- Interceptor
- RetryInterceptor
Constructors
- RetryInterceptor({RetryConfig? config, required DioProvider dioProvider})
Properties
- config → RetryConfig
-
final
- dioProvider → DioProvider
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
DioException err, ErrorInterceptorHandler handler) → void -
Called when an exception was occurred during the request.
override
-
onRequest(
RequestOptions options, RequestInterceptorHandler handler) → void -
Called when the request is about to be sent.
inherited
-
onResponse(
Response response, ResponseInterceptorHandler handler) → void -
Called when the response is about to be resolved.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited