RetryInterceptor class
Retries failed requests up to maxAttempts times with exponential back-off.
Only retries on ConnectionException and TimeoutException by default. Override shouldRetry to customise the retry predicate.
- Inheritance
-
- Object
- Interceptor
- RetryInterceptor
Constructors
- RetryInterceptor({int maxAttempts = 3, Duration initialDelay = const Duration(milliseconds: 500)})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialDelay → Duration
-
final
- maxAttempts → int
-
final
- 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(
NetworkException error, ErrorHandler handler) → void -
Called whenever an error occurs (network, timeout, or a rejection from
onRequest / onResponse). You may call
handler.resolveto recover.override -
onRequest(
RequestContext context, RequestHandler handler) → void -
Called before the request is sent. Mutate
handler.contextor callhandler.rejectto abort.inherited -
onResponse(
ResponseContext context, ResponseHandler handler) → void -
Called after a response is received (any status code). You may call
handler.rejectto convert a response into an error.inherited -
shouldRetry(
NetworkException error, int attempt) → bool -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited