Index: lib/src/io_io.dart |
diff --git a/lib/src/io_io.dart b/lib/src/io_io.dart |
index 619dfed0afea70ce20b1e210979feb7bb74d95f6..04506515b204444a20e9312e8452b9c7c1b62850 100644 |
--- a/lib/src/io_io.dart |
+++ b/lib/src/io_io.dart |
@@ -76,7 +76,8 @@ Future<String> readAsString(Uri uri, Encoding encoding) async { |
// Special case LATIN-1 since it is common and doesn't need decoding. |
int length = response.contentLength; |
if (length < 0) length = 0; |
- var buffer = new Uint8Buffer(length); |
+ // Create empty buffer with capacity matching contentLength. |
+ var buffer = new Uint8Buffer(length)..length = 0; |
await for (var bytes in response) { |
buffer.addAll(bytes); |
} |