0PricingLogin
Dart Academy · Lesson

Streaming Large Files

Process files chunk by chunk.

Why Not Read It All

readAsString loads the whole file into memory. For a huge log or video that can crash your program, so you stream it instead.

Open a Read Stream

Call openRead on a File to get a stream of byte chunks. You process each chunk and let the old ones go.

final stream = File('big.log').openRead();

All lessons in this course

  1. Reading and Writing Files
  2. Directories, Paths, and FileSystemEntity
  3. Streaming Large Files
  4. Stdin, Stdout, and Process Args
← Back to Dart Academy