dio_retry_plus 2.0.8 copy "dio_retry_plus: ^2.0.8" to clipboard
dio_retry_plus: ^2.0.8 copied to clipboard

A plugin for dio that retries failed requests.

dio_retry_plus #

A plugin for dio that retries failed requests.

Usage #

import 'package:dio_retry_plus/dio_retry_plus.dart';
copied to clipboard

Basic configuration

final dio = Dio()
  ..interceptors.add(RetryInterceptor());
copied to clipboard

Global retry options

final dio = Dio()
  ..interceptors.add(RetryInterceptor(
    options: const RetryOptions(
      retries: 3, // Number of retries before a failure
      retryInterval: const Duration(seconds: 1), // Interval between each retry
      retryEvaluator: (error) => error.type != DioErrorType.CANCEL && error.type != DioErrorType.RESPONSE, // Evaluating if a retry is necessary regarding the error. It is a good candidate for updating authentication token in case of a unauthorized error (be careful with concurrency though)
    )
  )
);
copied to clipboard

Sending a request with options

final response = await dio.get("http://www.flutter.dev", options: Options(
    extra: RetryOptions(
      retryInterval: const Duration(seconds: 10),
    ).toExtra(),
  ));
copied to clipboard

Sending a request without retry

final response = await dio.get("http://www.flutter.dev", options: Options(
    extra: RetryOptions.noRetry().toExtra(),
  ));
copied to clipboard

Logging retry operations

final dio = Dio()
  ..interceptors.add(RetryInterceptor(logger: Logger("Retry")));
copied to clipboard

Features and bugs #

Please file issues.

28
likes
110
points
488
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.26 - 2025.04.10

A plugin for dio that retries failed requests.

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on dio_retry_plus