FetchStrategyBuilder class

Builds a FetchStrategy function that retries up to a certain amount of times for up to a certain amount of time.

Pauses between retries with pauses growing exponentially (known as exponential backoff). Each attempt is subject to a timeout. Retries only those HTTP status codes considered transient by a transientHttpStatusCodePredicate function.

Constructors

FetchStrategyBuilder({Duration timeout = const Duration(seconds: 30), Duration totalFetchTimeout = const Duration(minutes: 1), int maxAttempts = 5, Duration initialPauseBetweenRetries = const Duration(seconds: 1), num exponentialBackoffMultiplier = 2, TransientHttpStatusCodePredicate transientHttpStatusCodePredicate = defaultTransientHttpStatusCodePredicate})
Creates a fetch strategy builder.
const

Properties

exponentialBackoffMultiplier → num
The pause between retries is multiplied by this number with each attempt, causing it to grow exponentially.
final
hashCode → int
The hash code for this object.
no setterinherited
initialPauseBetweenRetries → Duration
Initial amount of time between retries.
final
maxAttempts → int
Maximum number of attempts a strategy will make before giving up.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timeout → Duration
Maximum amount of time a single fetch attempt is allowed to take.
final
totalFetchTimeout → Duration
A strategy built by this builder will retry for up to this amount of time before giving up.
final
transientHttpStatusCodePredicate → TransientHttpStatusCodePredicate
A function that determines whether a given HTTP status code should be retried.
final

Methods

build() → FetchStrategy
Builds a FetchStrategy that operates using the properties of this builder.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

defaultTransientHttpStatusCodePredicate(int statusCode) → bool
Uses defaultTransientHttpStatusCodes to determine if the statusCode is transient.

Constants

defaultTransientHttpStatusCodes → const List<int>
A list of HTTP status codes that can generally be retried.