dio_retry_interceptor 0.0.1%2B1

SDKflutter
Platformandroidioswindowslinuxmacosweb

A Dio interceptor that retries failed requests on network reconnection.

dio_retry_interceptor

A custom Dio interceptor for Flutter/Dart that automatically retries HTTP requests when network connectivity is restored. Ideal for handling flaky or slow network conditions.


✨ Features

  • ✅ Retries failed requests on connection error or timeout
  • 🔁 Supports configurable retry attempts
  • 🔌 Checks connectivity before retrying
  • 🛠️ Toggle retry for POST/PUT requests
  • 🐞 Optional debug logs for retry attempts

🚀 Getting Started

Installation

Add this to your pubspec.yaml:

dependencies:
  dio_retry_interceptor: ^<latest_version>

Then run:

flutter pub get

Usage

import 'package:dio/dio.dart';
import 'package:dio_retry_interceptor/dio_retry_interceptor.dart';

...

final dio = Dio();

dio.interceptors.add(
  RetryOnConnectionChangeInterceptor(
    dio,
    maxRetryAttempts: 3,
    retryPost: false,
    enableLogging: true,
  ),
);

Optionally Mark a Request as Retryable (for non-GET)
await dio.post(
  '/your-api',
  data: {...},
  options: Options(
    extra: {'retryable': true},
  ),
);


OptionDescriptionDefault
maxRetryAttemptsMax number of retry attempts per request3
retryPostAllow retry for POST/PUT requestsfalse
enableLoggingShow console logs for each retry attemptfalse

Contributors

Feel free to open issues or submit PRs to improve this package.