dio_retry 0.1.9-beta copy "dio_retry: ^0.1.9-beta" to clipboard
dio_retry: ^0.1.9-beta copied to clipboard

A starting point for Dart libraries or applications.

example/example.dart

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.interceptors.add(RetryInterceptor(
    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");
  }
}
21
likes
30
pub points
64%
popularity

Publisher

unverified uploader

A starting point for Dart libraries or applications.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dio, logging, meta

More

Packages that depend on dio_retry