render method
Renders the current buffer to the terminal.
Automatically calls stdout.flush() to ensure output is visible immediately in TTY environments. This prevents buffering issues where ANSI sequences might not be displayed until program exit.
Set autoFlush to false for high-performance scenarios where you want
to control flushing manually.
Note: After calling render(), the current buffer is invalidated. Any subsequent operations on the old buffer will throw StateError. Get a fresh buffer via nextBuffer.
Implementation
void render({bool force = false, bool? autoFlush}) {
if (_disposed) throw StateError('Renderer is disposed');
_bindings.render(_ptr, force);
final shouldFlush = autoFlush ?? _autoFlush;
if (shouldFlush) {
stdout
.flush(); // Force terminal output immediately after C library render
}
// Invalidate cached buffer - operations on stale buffer will fail fast
_nextBuffer?.invalidate();
_nextBuffer = null; // Clear reference to fetch fresh buffer next frame
}