readAsBytes method

Future<List<int>> readAsBytes()

Reads the contents of the file into a single linear buffer.

Note that this leads to holding the whole file in memory, which might not be ideal for large files.w

Implementation

Future<List<int>> readAsBytes() {
  return data
      .fold<BytesBuilder>(BytesBuilder(), (bb, out) => bb..add(out))
      .then((bb) => bb.takeBytes());
}