Renderer.create constructor

Renderer.create(
  1. int width,
  2. int height, {
  3. bool testing = false,
})

Creates a Renderer.

Set testing to true to redirect all native render output to /dev/null. Useful in test harnesses that capture render state via direct buffer access and do not want ANSI sequences written to stdout.

Implementation

factory Renderer.create(int width, int height, {bool testing = false}) {
  final bindings = OpenTuiBindings();
  final ptr = bindings.createRenderer(width, height, testing: testing);
  if (ptr == nullptr) {
    throw StateError(
      'Failed to create renderer. Ensure libopentui is installed and loadable.',
    );
  }
  return Renderer._(bindings, ptr);
}