dio_retry_plus

Creator: coderz1093

Last updated:

0 purchases

dio_retry_plus Image
dio_retry_plus Images

Languages

Categories

Add to Cart

Description:

dio retry plus

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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.