Skip to content

Commit

Permalink
🔥 Remove redundant warnings (#2309)
Browse files Browse the repository at this point in the history
Fixes #2306

The warning will be raised within the adapter.
  • Loading branch information
AlexV525 authored Oct 7, 2024
1 parent b4c5bc6 commit 945d487
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
7 changes: 3 additions & 4 deletions dio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ See the [Migration Guide][] for the complete breaking changes list.**

## Unreleased

*None.*
- Removes redundant warnings when composing request options on Web.

## 5.7.0

- Graceful handling of responses with nonzero `Content-Length`, `Content-Type` json, but empty body
- Empty responses are now transformed to `null`

- Graceful handling of responses with nonzero `Content-Length`, `Content-Type` that is json, and empty payload.
- Empty responses are now transformed to `null`.

## 5.6.0

Expand Down
14 changes: 0 additions & 14 deletions dio/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,6 @@ class Options {
ProgressCallback? onReceiveProgress,
StackTrace? sourceStackTrace,
}) {
if (data != null && kIsWeb) {
if (sendTimeout != null && sendTimeout! > Duration.zero) {
warningLog(
'sendTimeout cannot be used without a request body to send on Web',
StackTrace.current,
);
}
if (onSendProgress != null) {
warningLog(
'onSendProgress cannot be used without a request body to send on Web',
StackTrace.current,
);
}
}
final query = <String, dynamic>{};
query.addAll(baseOpt.queryParameters);
if (queryParameters != null) {
Expand Down
9 changes: 5 additions & 4 deletions plugins/web_adapter/lib/src/adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class BrowserHttpClientAdapter implements HttpClientAdapter {
}
});

final onSendProgress = options.onSendProgress;
final sendTimeout = options.sendTimeout ?? Duration.zero;
final connectTimeout = options.connectTimeout ?? Duration.zero;
final receiveTimeout = options.receiveTimeout ?? Duration.zero;

final xhrTimeout = (connectTimeout + receiveTimeout).inMilliseconds;
xhr.timeout = xhrTimeout;

Expand Down Expand Up @@ -138,7 +140,6 @@ class BrowserHttpClientAdapter implements HttpClientAdapter {
});
}

final onSendProgress = options.onSendProgress;
if (onSendProgress != null) {
xhrUploadProgressStream.listen((event) {
onSendProgress(event.loaded, event.total);
Expand All @@ -147,13 +148,13 @@ class BrowserHttpClientAdapter implements HttpClientAdapter {
} else {
if (sendTimeout > Duration.zero) {
warningLog(
'sendTimeout cannot be used without a request body to send',
'sendTimeout cannot be used without a request body to send on Web',
StackTrace.current,
);
}
if (options.onSendProgress != null) {
if (onSendProgress != null) {
warningLog(
'onSendProgress cannot be used without a request body to send',
'onSendProgress cannot be used without a request body to send on Web',
StackTrace.current,
);
}
Expand Down

0 comments on commit 945d487

Please sign in to comment.