RetryPolicy class abstract
Abstract interface for retry policies
Retry policies determine when and how to retry failed tasks. Implement this interface to create custom retry strategies.
Example:
class MyRetryPolicy extends RetryPolicy {
@override
bool shouldRetry(int attempt, Object error, StackTrace stackTrace) {
return attempt < 3 && error is NetworkException;
}
@override
Duration? nextDelay(int attempt, Object error, StackTrace stackTrace) {
return Duration(seconds: attempt);
}
}
- Implementers
Constructors
- RetryPolicy()
-
Creates a retry policy
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
nextDelay(
int attempt, Object error, StackTrace stackTrace) → Duration? - Returns the delay before the next retry, or null for immediate retry
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
shouldRetry(
int attempt, Object error, StackTrace stackTrace) → bool - Whether the task should be retried
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited