LineRingBuffer
Category: Shell
Source: line_ring_buffer.dart
Classes
LineRingBuffer
A ring buffer that keeps the most recent lines of output, bounded by both line count and total byte size.
Used to capture process output without unbounded memory growth — for example, a background job that runs for hours will only keep its last [maxLines] lines. Partial lines (text without a trailing newline) are held in an internal buffer until the next [addText] call completes them.
Constructor
dart
LineRingBuffer({required this.maxLines, required this.maxBytes})Properties
| Property | Type | Description |
|---|---|---|
maxLines | int | |
maxBytes | int | |
lineCount | int get | The number of lines currently held, including any buffered partial line. |
lineCount | int get | The number of lines currently held, including any buffered partial line. |
Methods
void addText(String text)
Appends raw text to the buffer, splitting it into lines on \n.
If [text] doesn't end with a newline, the trailing fragment is held internally and prepended to the next [addText] call. This means you can safely feed in arbitrary chunks from a process stream.