dio_retry 0.1.0-beta dio_retry: ^0.1.0-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 caching options
final dio = Dio()
..interceptors.add(CacheInterceptor(
options: const CacheInterceptorRequestExtra(
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(CacheInterceptor(logger: Logger("Retry")));
Availables stores #
name | description |
---|---|
MemoryCacheStore | Stores all cached responses in a map in memory |
FileCacheStore | Stores each request in a dedicated file |
BackupCacheStore | Reads values primarly from memory and backup values to specified store (ex: a FileCacheStore) |
FilteredCacheStore | Ignoring responses for save |
Features and bugs #
Please file issues.