diff --git a/dio/lib/src/adapters/io_adapter.dart b/dio/lib/src/adapters/io_adapter.dart index 795c0fe61..50feaff6d 100644 --- a/dio/lib/src/adapters/io_adapter.dart +++ b/dio/lib/src/adapters/io_adapter.dart @@ -238,12 +238,12 @@ class IOHttpClientAdapter implements HttpClientAdapter { }); } - responseSubscription = responseStream.listen( + responseSubscription = responseStream.cast().listen( (data) { watchReceiveTimeout(); // Always true if the receive timeout was not set. if (receiveStopwatch.elapsed <= receiveTimeout) { - responseSink.add(data is Uint8List ? data : Uint8List.fromList(data)); + responseSink.add(data); } }, onError: (error, stackTrace) { diff --git a/dio/test/options_test.dart b/dio/test/options_test.dart index 086fe8b34..f7d7a8464 100644 --- a/dio/test/options_test.dart +++ b/dio/test/options_test.dart @@ -561,8 +561,7 @@ void main() { when(response.reasonPhrase).thenReturn('OK'); when(response.isRedirect).thenReturn(false); when(response.redirects).thenReturn([]); - when(response.transform(any)) - .thenAnswer((_) => Stream.empty()); + when(response.cast()).thenAnswer((_) => Stream.empty()); return Future.value(request); });