withRetry<T> method

Future<T> withRetry<T>(
  1. Future<T> fn(
    1. void logger(
      1. Uri uri
      )
    ), {
  2. required String gerund,
  3. FutureOr<bool> retryIf(
    1. Exception
    )?,
  4. FutureOr<void> onRetry(
    1. Exception
    )?,
})

Retry a request.

Implementation

Future<T> withRetry<T>(
  Future<T> Function(void Function(Uri uri) logger) fn, {
  required String gerund,
  FutureOr<bool> Function(Exception)? retryIf,
  FutureOr<void> Function(Exception)? onRetry,
}) {
  final retry = _InternalRetry(
    gerund: gerund,
    emit: logger.emit,
    fn: fn,
    retryIf: retryIf,
    onRetry: onRetry,
  );

  return _retryOptions.retry<T>(
    retry,
    retryIf: retry.retryIf,
    onRetry: retry.onRetry,
  );
}