Skip to content

Commit

Permalink
⚡️ Check Uint8List before doing byte conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Nov 26, 2023
1 parent d589d08 commit 8bf54bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dio/lib/src/adapters/browser_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ class BrowserHttpClientAdapter implements HttpClientAdapter {
}
final completer = Completer<Uint8List>();
final sink = ByteConversionSink.withCallback(
(bytes) => completer.complete(Uint8List.fromList(bytes)),
(bytes) => completer.complete(
bytes is Uint8List ? bytes : Uint8List.fromList(bytes),
),
);
requestStream.listen(
sink.add,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class ConversionLayerAdapter implements HttpClientAdapter {
if (requestStream != null) {
final completer = Completer<Uint8List>();
final sink = ByteConversionSink.withCallback(
(bytes) => completer.complete(Uint8List.fromList(bytes)),
(bytes) => completer.complete(
bytes is Uint8List ? bytes : Uint8List.fromList(bytes),
),
);
requestStream.listen(
sink.add,
Expand Down

0 comments on commit 8bf54bc

Please sign in to comment.