Skip to content

Commit

Permalink
add request retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ksh-b committed Jul 8, 2024
1 parent bb1ec1f commit 62b40aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/brain/dio_manager.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import 'package:dio/dio.dart';
import 'package:dio_smart_retry/dio_smart_retry.dart';

Dio dio() {
return Dio()..options = BaseOptions(validateStatus: (status) => true);
final dio_ = Dio();
dio_.options = BaseOptions(validateStatus: (status) => true);
dio_.interceptors.add(
RetryInterceptor(
dio: dio_,
logPrint: print,
retries: 3,
retryDelays: const [
Duration(seconds: 2),
Duration(seconds: 3),
Duration(seconds: 5),
],
),
);
return dio_;
}
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.2.2"
dio_smart_retry:
dependency: "direct main"
description:
name: dio_smart_retry
sha256: "3d71450c19b4d91ef4c7d726a55a284bfc11eb3634f1f25006cdfab3f8595653"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
dynamic_color:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
device_info_plus: ^10.1.0
dio: ^5.4.3+1
dio_cache_interceptor_hive_store: ^3.2.2
dio_smart_retry: ^6.0.0
dynamic_color: ^1.7.0
flutter:
sdk: flutter
Expand Down

0 comments on commit 62b40aa

Please sign in to comment.