Renderer.create constructor

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

Opens guarded bindings and allocates a native renderer.

Set testing to true to use OpenTUI's non-terminal testing sink. This is useful in harnesses that capture render state through direct buffer access instead of terminal output.

Throws ArgumentError when width or height is non-positive.

Implementation

factory Renderer.create(int width, int height, {bool testing = false}) {
  validateRendererDimensions(width, height);
  final bindings = OpenTuiBindings();
  final handle = bindings.createRenderer(width, height, testing: testing);
  return Renderer._(bindings, handle, testing: testing);
}