Skip to content

Commit

Permalink
fix disableRetry if extra is const
Browse files Browse the repository at this point in the history
  • Loading branch information
binSaed committed Sep 26, 2023
1 parent a13117e commit 4dcd959
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/src/retry_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RetryInterceptor extends Interceptor {
'retryableExtraStatuses',
);
}
if(retries < 0) {
if (retries < 0) {
throw ArgumentError(
'[retries] cannot be less than 0',
'retries',
Expand Down Expand Up @@ -191,6 +191,7 @@ class RetryInterceptor extends Interceptor {
}

var _multipartFileChecked = false;

void _printErrorIfRequestHasMultipartFile(RequestOptions options) {
if (_multipartFileChecked) return;
if (options.data is FormData) {
Expand Down Expand Up @@ -226,6 +227,8 @@ extension RequestOptionsX on RequestOptions {
extension OptionsX on Options {
bool get disableRetry => (extra?[_kDisableRetryKey] as bool?) ?? false;

set disableRetry(bool value) =>
(extra ??= <String, dynamic>{})[_kDisableRetryKey] = value;
set disableRetry(bool value) {
extra = Map.of(extra ??= <String, dynamic>{});
extra![_kDisableRetryKey] = value;
}
}

0 comments on commit 4dcd959

Please sign in to comment.