diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart index 47877528..6d873624 100644 --- a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart +++ b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart @@ -8,14 +8,12 @@ export 'package:cookie_jar/cookie_jar.dart'; extension DynamiteHttpClientResponseBody on HttpClientResponse { Future get bodyBytes async { - final chunks = await toList(); - if (chunks.isEmpty) { - return Uint8List(0); - } - return Uint8List.fromList(chunks.reduce((final value, final element) => [...value, ...element])); + final data = await expand((final element) => element).toList(); + + return Uint8List.fromList(data); } - Future get body async => utf8.decode(await bodyBytes); + Future get body => transform(utf8.decoder).join(); } class DynamiteResponse {