retry_bot 1.0.1 copy "retry_bot: ^1.0.1" to clipboard
retry_bot: ^1.0.1 copied to clipboard

Dio interceptor Retry which makes retrying API Call When getting a timeout.

🤖 Retry Bot #

pub package style: very good analysis License: MIT

Performing HTTP requests is all fun and games until there's no internet connection. Sure, you can display a sad error message or a "Chrome dinosaur" to the user, but wouldn't it be better to take the initiative and automatically retry the request when the user connects to a WiFi network or enables mobile data? This is precisely what we're going to introduce with ** Retry Bot**

Usage #

Add a dependency in your pubspec. yaml:

dependencies:
  retry_bot: ^1.0.1

Simple usage using Retry Bot:

  • First: Create a new instance from Dio
import 'package:dio/dio.dart';

final dio = Dio();
  • Second: Create a new instance from Connectivity
import 'package:connectivity_plus/connectivity_plus.dart';

final connectivity = Connectivity();
  • Third: Create a new instance from DioConnectivityRequest and pass dio and connectivity objects as params
import 'package:retry_bot/retry_bot.dart';

final request = DioConnectivityRequest(
    connectivity: connectivity,
    dio: dio,
  );
  • Fourth: Create a new instance from OnRetryConnection and pass requests as params
import 'package:retry_bot/retry_bot.dart';

final retryInterceptor = OnRetryConnection(
      request: request,
    );
  • Finally: Add your OnRetryConnection object to Dio Interceptors
import 'package:retry_bot/retry_bot.dart';

dio.interceptors.add(retryInterceptor);

Simple Usage #

import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dio/dio.dart';
import 'package:retry_bot/retry_bot.dart';

void main() {
  final dio = Dio();

  final connectivity = Connectivity();
  final request = DioConnectivityRequest(
    connectivity: connectivity,
    dio: dio,
  );
  final retryInterceptor = OnRetryConnection(
    request: request,
  );

  dio.interceptors.add(retryInterceptor);
}

23
likes
140
pub points
55%
popularity

Publisher

verified publisherflutterbots.dev

Dio interceptor Retry which makes retrying API Call When getting a timeout.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

connectivity_plus, dio, flutter

More

Packages that depend on retry_bot