super_request library

Classes

PollError<T>
PollEvent<T>
PollOptions
PollResult<T>
PollValue<T>
RequestCache<T>
RequestCancellationController
Owner of a RequestCancellationToken. Cancellation is idempotent.
A disposable token that is cancelled when any parent token is cancelled.
RequestCancellationReason
RequestCancellationToken
Read-only cancellation signal passed through a request pipeline.
RequestContext
Immutable data propagated through every request and wrapper.
RequestGenerationManager
Implements latest-wins requests, independently for each key.
RequestPipeline<T>
Reusable, immutable request pipeline.
RequestPoller
RequestQueue
FIFO queue with a configurable number of concurrently running requests.
RequestQueueStats
RequestQueueTask<T>
Handle returned immediately when a request enters a RequestQueue.
RequestScope
Owns a group of requests, typically for a page, component, or use case.
RequestServicePipeline<T, P>
Immutable builder for parameterized request wrappers.
RetryPolicy
SuperRequestClient
Creates lazy RequestCall values backed by Dio.
UseRequest<T, P>
Dart equivalent of the orchestration part of ahooks useRequest.
UseRequestState<T, P>

Enums

RequestCancellationKind
Why a request stopped before producing a usable value.
RequestQueueTaskState

Functions

cancellableDelay(Duration duration, RequestCancellationToken token) Future<void>
A delay that can be interrupted by request cancellation.
composeRequest<T>(RequestCall<T> request, Iterable<RequestWrapper<T>> wrappers) RequestCall<T>
Applies wrappers in declaration order: the first wrapper is outermost.
composeService<T, P>(RequestService<T, P> service, Iterable<RequestServiceWrapper<T, P>> wrappers) RequestService<T, P>
raceCancellation<T>(Future<T> future, RequestCancellationToken token) Future<T>
Completes with future, or throws as soon as token is cancelled.
requestCache<T, P>(RequestCache<T> cache, {required Object keyOf(P params), Duration ttl = const Duration(minutes: 5), bool deduplicate = true}) RequestServiceWrapper<T, P>
TTL cache with in-flight request deduplication.
requestDebounce<T, P>(Duration duration) RequestServiceWrapper<T, P>
Latest-call debounce. A newer invocation cancels the previous pending or running invocation and only the latest parameters reach the wrapped service.
requestThrottle<T, P>(Duration duration) RequestServiceWrapper<T, P>
Leading-edge throttle. Calls inside duration share the same result.
requestTimeout<T>(Duration duration) RequestWrapper<T>
retry<T>(RetryPolicy policy) RequestWrapper<T>
serviceFromCall<T, P>(RequestCall<T> create(P params)) RequestService<T, P>
Turns a parameter-dependent request factory into a service.
serviceRetry<T, P>(RetryPolicy policy) RequestServiceWrapper<T, P>
useRequest<T, P>(RequestService<T, P> service, {Iterable<RequestServiceWrapper<T, P>> wrappers = const [], UseRequestBefore<P>? onBefore, UseRequestSuccess<T, P>? onSuccess, UseRequestError<P>? onError, UseRequestFinally<P>? onFinally}) UseRequest<T, P>

Typedefs

PollRetryPredicate = FutureOr<bool> Function(Object error, StackTrace stackTrace, int attempt)
RequestCall<T> = Future<T> Function(RequestContext context)
RequestService<T, P> = Future<T> Function(P params, RequestContext context)
A request whose input and output types are both known at compile time.
RequestServiceWrapper<T, P> = RequestService<T, P> Function(RequestService<T, P> next)
RequestWrapper<T> = RequestCall<T> Function(RequestCall<T> next)
ResponseDecoder<T> = T Function(Object? data, Response<Object?> response)
RetryPredicate = bool Function(Object error, StackTrace stackTrace, int attempt)
UseRequestBefore<P> = void Function(P params)
UseRequestError<P> = void Function(Object error, StackTrace stackTrace, P params)
UseRequestFinally<P> = void Function(P params)
UseRequestSuccess<T, P> = void Function(T data, P params)