dio_retry_plus 2.0.7 copy "dio_retry_plus: ^2.0.7" to clipboard
dio_retry_plus: ^2.0.7 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.

26
likes
100
pub points
84%
popularity

Publisher

unverified uploader

A plugin for dio that retries failed requests.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on dio_retry_plus