dio_retry 0.1.8-beta

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

dio_retry #

A plugin for dio that retries failed requests.

Usage #

import 'package:dio_retry/dio_retry.dart';

Basic configuration #

final dio = Dio()

Global retry options #

final dio = Dio()
    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),

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.

1.0.0 #

  • Initial version, created by Stagehand


import 'package:dio/dio.dart';
import 'package:dio_retry/dio_retry.dart';
import 'package:logging/logging.dart';

main() async {
  // Displaying logs
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    print('${record.level.name}: ${record.time}: ${record.message}');

  final dio = Dio();

  // Add the interceptor with optional options
    dio: dio,
    logger: Logger("Retry"),
    options: const RetryOptions(
      retryInterval: const Duration(seconds: 5),

  /// Sending a failing request for 3 times with a 5s interval
  try {
    await dio.get("http://www.mqldkfjmdisljfmlksqdjfmlkj.dev");
  } catch (e) {
    print("End error : $e");

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dio_retry: ^0.1.8-beta

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dio_retry/dio_retry.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, other

Primary library: package:dio_retry/dio_retry.dart with components: io.

Health suggestions

Format lib/dio_retry.dart.

Run dartfmt to format lib/dio_retry.dart.

Format lib/src/options.dart.

Run dartfmt to format lib/src/options.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (dio).

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
dio ^2.1.7 2.2.2 3.0.4
logging ^0.11.3 0.11.3+2
meta ^1.1.6 1.1.8
Transitive dependencies
cookie_jar 1.0.1
Dev dependencies
pedantic ^1.0.0
test ^1.0.0