diff --git a/lib/brain/dio_manager.dart b/lib/brain/dio_manager.dart index 3f4a59a..d573ef4 100644 --- a/lib/brain/dio_manager.dart +++ b/lib/brain/dio_manager.dart @@ -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_; } diff --git a/pubspec.lock b/pubspec.lock index ee5e62a..d168d06 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: diff --git a/pubspec.yaml b/pubspec.yaml index 8ecb5b3..d013424 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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