{"id":23909289,"url":"https://github.com/rodion-m/dio_smart_retry","last_synced_at":"2025-04-12T21:29:41.609Z","repository":{"id":38333603,"uuid":"391202112","full_name":"rodion-m/dio_smart_retry","owner":"rodion-m","description":"Flexible retry library for Dio. A next generation of an abandoned dio_retry package.","archived":false,"fork":false,"pushed_at":"2024-12-02T08:31:49.000Z","size":59,"stargazers_count":93,"open_issues_count":6,"forks_count":46,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T01:08:16.495Z","etag":null,"topics":["attempts","dart","dio","dio-retry","flutter","repeat","retrying"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodion-m.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-30T22:41:30.000Z","updated_at":"2025-03-29T16:02:01.000Z","dependencies_parsed_at":"2023-01-25T17:31:52.677Z","dependency_job_id":"c5a3ffa3-465e-4b8d-8864-cd86882afbd1","html_url":"https://github.com/rodion-m/dio_smart_retry","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-m%2Fdio_smart_retry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-m%2Fdio_smart_retry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-m%2Fdio_smart_retry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodion-m%2Fdio_smart_retry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodion-m","download_url":"https://codeload.github.com/rodion-m/dio_smart_retry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248634584,"owners_count":21137073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attempts","dart","dio","dio-retry","flutter","repeat","retrying"],"created_at":"2025-01-05T05:18:59.405Z","updated_at":"2025-04-12T21:29:41.583Z","avatar_url":"https://github.com/rodion-m.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Pub Version](https://img.shields.io/pub/v/dio_smart_retry?logo=dart\u0026logoColor=white)](https://pub.dev/packages/dio_smart_retry/)\n[![Dart SDK Version](https://badgen.net/pub/sdk-version/dio_smart_retry)](https://pub.dev/packages/dio_smart_retry/)\n[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)\n[![License](https://img.shields.io/github/license/rodion-m/dio_smart_retry)](https://github.com/rodion-m/dio_smart_retry/blob/master/LICENSE)\n\n# Dio Smart Retry\nFlexible retry library for Dio package. This is a next generation of an abandoned `dio_retry` package. \\\nBy default, the request will be retried only for appropriate retryable http statuses. \\\nAlso, it supports dynamic delay between retries. \\\n**Null Safety.**\n\n## Contents\n\n- [Dio Smart Retry](#dio-smart-retry)\n  - [Contents](#contents)\n  - [Getting Started for Dio](#getting-started-for-dio)\n  - [Usage](#usage)\n  - [Default retryable status codes list](#default-retryable-status-codes-list)\n  - [Disable retry](#disable-retry)\n  - [Add extra retryable status codes](#add-extra-retryable-status-codes)\n  - [Override retryable statuses](#override-retryable-statuses)\n\n## Getting Started for Dio\n\n1. Add package to pubspec.yaml: `dio_smart_retry: ^7.0.0` **\n2. Import package: `import 'package:dio_smart_retry/dio_smart_retry.dart'`\n\n** For the old dio (ver. 4.+) use `dio_smart_retry: ^1.4.0`\n\n## Usage\n\nJust add an interceptor to your dio:\n```dart\nfinal dio = Dio();\n// Add the interceptor\ndio.interceptors.add(RetryInterceptor(\n  dio: dio,\n  logPrint: print, // specify log function (optional)\n  retries: 3, // retry count (optional)\n  retryDelays: const [ // set delays between retries (optional)\n    Duration(seconds: 1), // wait 1 sec before first retry\n    Duration(seconds: 2), // wait 2 sec before second retry\n    Duration(seconds: 3), // wait 3 sec before third retry\n  ],\n));\n\n/// Sending a failing request for 3 times with 1s, then 2s, then 3s interval\nawait dio.get('https://mock.codes/500');\n```\n[See `example/dio_smart_retry_example.dart`](https://github.com/rodion-m/dio_smart_retry/blob/master/example/dio_smart_retry_example.dart).\n\n## Default retryable status codes list\nResponses with these http status codes will be retried by default:\n* 408: RequestTimeout\n* 429: TooManyRequests\n* 500: InternalServerError\n* 502: BadGateway\n* 503: ServiceUnavailable\n* 504: GatewayTimeout\n* 440: LoginTimeout (IIS)\n* 460: ClientClosedRequest (AWS Elastic Load Balancer)\n* 499: ClientClosedRequest (ngnix)\n* 520: WebServerReturnedUnknownError\n* 521: WebServerIsDown\n* 522: ConnectionTimedOut\n* 523: OriginIsUnreachable\n* 524: TimeoutOccurred\n* 525: SSLHandshakeFailed\n* 527: RailgunError\n* 598: NetworkReadTimeoutError\n* 599: NetworkConnectTimeoutError\n[It's possible to override this list](#override-retryable-statuses)\n\n## Disable retry\nIt's possible to manually disable retry for a specified request. Use `disableRetry` extension for that:\n```dart\nfinal request = RequestOptions(path: '/')\n  ..disableRetry = true;\nawait dio.fetch\u003cString\u003e(request);\n```\nor\n```dart\nfinal options = Options()\n  ..disableRetry = true;\nawait dio.get\u003cString\u003e('/', options: options);\n```\n\n## Add extra retryable status codes\nIt's possible to add you own retryable status codes. Use `retryableExtraStatuses` parameter for that. Here is an example:\n```dart\nRetryInterceptor(\n  dio: dio,\n  retryableExtraStatuses: { status401Unauthorized },\n)\n```\nor:\n```dart\nRetryInterceptor(\n  dio: dio,\n  retryableExtraStatuses: { 401 },\n)\n```\n\n## Override retryable statuses\nIt's possible to override default retryable status codes list. Just make new instance of `DefaultRetryEvaluator` and pass your status codes there. \\\nHere is an example:\n```dart\nfinal myStatuses = { status400BadRequest, status409Conflict };\ndio.interceptors.add(\n  RetryInterceptor(\n    dio: dio,\n    logPrint: print,\n    retryEvaluator: DefaultRetryEvaluator(myStatuses).evaluate,\n  ),\n);\n\nawait dio.get\u003cdynamic\u003e('https://mock.codes/400');\n```\n\n## Migrating to 7.0\n\nUse `MultipartFile` instead of `MultipartFileRecreatable`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodion-m%2Fdio_smart_retry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodion-m%2Fdio_smart_retry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodion-m%2Fdio_smart_retry/lists"}