Skip to content

Commit

Permalink
Add support of dio ver. 5.+
Browse files Browse the repository at this point in the history
  • Loading branch information
rodion-m committed Feb 16, 2023
1 parent afdb872 commit ce295aa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 5.0.0
- Add supporting of the new dio 5.+

## 2.0.1-diox
- Add supporting of [DioX](https://pub.dev/packages/diox)

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Also, it supports dynamic delay between retries. \

## Getting Started for Dio

1. Add package to pubspec.yaml: `dio_smart_retry: ^2.1.0`
1. Add package to pubspec.yaml: `dio_smart_retry: ^5.0.0` **
2. Import package: `import 'package:dio_smart_retry/dio_smart_retry.dart'`

** For the old dio (ver. 4.+) use `dio_smart_retry: ^1.4.0`

## Usage

Just add an interceptor to your dio:
Expand Down
2 changes: 1 addition & 1 deletion example/dio_smart_retry_example.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';

import 'package:dio_smart_retry/dio_smart_retry.dart';
import 'package:dio/dio.dart';
import 'package:dio_smart_retry/dio_smart_retry.dart';

Future<dynamic> main() async {
final dio = Dio();
Expand Down
2 changes: 1 addition & 1 deletion lib/dio_smart_retry.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Retry library for Dio and DioX package made with love
/// Retry library for Dio package made with love
library dio_smart_retry;

export 'src/default_retry_evaluator.dart';
Expand Down
8 changes: 7 additions & 1 deletion lib/src/retry_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class RetryInterceptor extends Interceptor {
'retryableExtraStatuses',
);
}
if(retries < 0) {
throw ArgumentError(
'[retries] cannot be less than 0',
'retries',
);
}
}

static const _multipartRetryHelpLink =
Expand Down Expand Up @@ -120,7 +126,7 @@ class RetryInterceptor extends Interceptor {
'trying again '
'(attempt: $attempt/$retries, '
'wait ${delay.inMilliseconds} ms, '
'error: ${err.error})',
'error: ${err.error ?? err})',
);

var requestOptions = err.requestOptions;
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dio_smart_retry
description: Retry library for Dio and Dio package made with love. By default, the request will be retried only for appropriate retryable http statuses.
version: 2.0.1
version: 5.0.0
repository: https://github.com/rodion-m/dio_smart_retry
issue_tracker: https://github.com/rodion-m/dio_smart_retry/issues
homepage: https://github.com/rodion-m/dio_smart_retry
Expand All @@ -15,6 +15,6 @@ dependencies:
path: ^1.8.2

dev_dependencies:
dart_code_metrics: ^5.5.1
dart_code_metrics: ^5.6.0
test: ^1.23.1
very_good_analysis: ^4.0.0+1

0 comments on commit ce295aa

Please sign in to comment.