dio_retry 0.1.2-beta dio_retry: ^0.1.2-beta copied to clipboard
A starting point for Dart libraries or applications.
dio_retry #
A plugin for dio that retries failed requests.
Usage #
import 'package:dio_retry/dio_retry.dart';
Basic configuration
final dio = Dio()
..interceptors.add(RetryInterceptor());
Global retry options
final dio = Dio()
..interceptors.add(RetryInterceptor(
options: const RetryInterceptorRequestExtra(
retries: 3, // Number of retries before a failure
retryInterval: const Duration(seconds: 1), // Interval between each retry
)
)
);
Sending a request with options
final response = await dio.get("http://www.flutter.dev", options: Options(
extra: RetryInterceptorRequestExtra(
retryInterval: const Duration(seconds: 10),
).toExtra(),
));
Sending a request without retry
final response = await dio.get("http://www.flutter.dev", options: Options(
extra: RetryInterceptorRequestExtra.noRetry().toExtra(),
));
Logging retry operations
final dio = Dio()
..interceptors.add(RetryInterceptor(logger: Logger("Retry")));
Features and bugs #
Please file issues.