dio_retry_plus 2.0.2 copy "dio_retry_plus: ^2.0.2" to clipboard
dio_retry_plus: ^2.0.2 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';

Basic configuration

final dio = Dio()
  ..interceptors.add(RetryInterceptor());

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)
    )
  )
);

Sending a request with options

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

Sending a request without retry

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

Logging retry operations

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

Features and bugs #

Please file issues.

28
likes
0
points
239
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin for dio that retries failed requests.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on dio_retry_plus