RetryQueue class

Connectivity-aware request queue with exponential backoff retry.

  • Requests submitted while offline are parked and replayed when online.
  • Online requests that fail are retried with exponential backoff.
  • Queue size is bounded — oldest item is evicted when full.

Usage:

final queue = RetryQueue(maxRetries: 3);
queue.attach(SmartConnectivityMonitor.instance.stateStream);

final result = await queue.enqueue(() => http.get(myApiUrl));

Constructors

RetryQueue({int maxRetries = 3, Duration baseDelay = const Duration(seconds: 2), int maxQueueSize = 50})

Properties

baseDelay Duration
final
hashCode int
The hash code for this object.
no setterinherited
maxQueueSize int
final
maxRetries int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

attach(Stream<ConnectivityState> stream) → void
Attach to the connectivity state stream. Must be called before enqueue.
dispose() → void
Cancel all pending requests and release resources.
enqueue<T>(RequestFn<T> fn) Future<T>
Enqueue a request.
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