RetryInterceptor class

An interceptor that retries requests if they fail.

If a CancelToken is provided in the original request, the subsequent requests triggered by this interceptor will be cancelled as well via internal delegation.

Inheritance

Constructors

RetryInterceptor.new({int maxRetries = 1, RetryCondition? shouldRetry, RetryDelay? delay, BeforeRetry? beforeRetry})

Properties

beforeRetryFunc BeforeRetry?
final
delayFunc RetryDelay
final
hashCode int
The hash code for this object.
no setterinherited
maxRetries int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldRetryFunc RetryCondition
final

Methods

afterResponse(HttpResponse response) Future<InterceptorResult<HttpResponse>>
Called before the response is returned.
override
beforeRequest(HttpRequest request) Future<InterceptorResult<HttpRequest>>
Called before the request is sent.
override
beforeRetry(int attempt, HttpRequest request, HttpResponse? response, RhttpException? exception) Future<HttpRequest?>
Called before each retry. May return a new request to be used for the current retry and all subsequent retries.
getDelay(int attempt) Duration
The delay between retries (including the delay before the initial retry). Override this method to customize the delay.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(RhttpException exception) Future<InterceptorResult<RhttpException>>
Called when an exception is thrown.
override
shouldRetry(HttpResponse? response, RhttpException? exception) bool
Whether to retry the request. Override this method to customize the retry logic.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

key → const String