render method

void render({
  1. bool force = false,
  2. bool? autoFlush,
})

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}) {
  _checkNotDisposed();
  try {
    _bindings.render(_handle, force);
    final shouldFlush = autoFlush ?? _autoFlush;
    if (shouldFlush) {
      stdout.flush();
    }
  } finally {
    // OpenTUI may have cleared or otherwise mutated the frame before it
    // reports failure. Never let callers reuse a potentially stale native
    // view, including when rendering or flushing throws.
    _invalidateBorrowedBuffers();
  }
}