パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.8

dio_retry_plus

失敗したリクエストを再試行するための、Dio用プラグインです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
837
いいね数
29
Pub ポイント
120

パッケージをインストール

flutter pub add dio_retry_plus

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

dio_retry_plus は、人気のある HTTP クライアントである Dio を拡張する Flutter パッケージで、失敗したリクエストに対して自動的に再試行する機能を追加しています。エラーの種類、ステータスコード、タイムアウトなどの設定可能な条件に基づいてリクエストを再試行することで、ネットワーク操作の信頼性を向上させます。このプラグインはさまざまな再試行戦略とバックオフメカニズムをサポートしており、堅牢なネットワーク耐障害性を必要とするアプリケーションに最適です。既存の Dio 設定とシームレスに統合され、Android、iOS、Web、macOS、Windows、Linux などすべての主要プラットフォームで動作します。

用途

  • 一時的なネットワーク障害の処理
  • APIコールの信頼性の向上
  • 失敗したリクエストによるユーザーのイライラを軽減する
  • オフライン優先のアプリパターンをサポートする
  • バックグラウンドタスクの再試行ロジックを自動化する

主な機能

  • 再試行条件のカスタマイズ
  • 指数バックオフのサポート
  • 再試行回数のカスタマイズ
  • Dioミドルウェアとの統合
  • タイムアウトまたは接続エラー時の自動再試行

適している対象

  • 信頼できないネットワーク接続を持つアプリ
  • 障害耐性を必要とするAPIクライアント
  • バックグラウンドデータ同期サービス
  • リアルタイムデータ取得アプリケーション
  • HTTP操作にDioを使用する開発者

注意事項

  • リトライが頻繁すぎると、遅延が増加する可能性があります
  • 無限ループを回避するためには注意深い構成が必要です
  • イデムポテンシーのみの操作には適していません
  • モバイルデバイスのバッテリー寿命に影響を与える可能性があります
  • シミュレートされたネットワーク障害シナリオでのテストが必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

dio_retry_plus

A plugin for dio that retries failed requests.

Usage

import 'package:dio_retry_plus/dio_retry_plus.dart';
Basic configuration
final dio = Dio()
  ..interceptors.add(RetryInterceptor());
Global retry options
final dio = Dio()
  ..interceptors.add(RetryInterceptor(
    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),
    ).toExtra(),
  ));
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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。