drawBatch method

void drawBatch(
  1. Iterable<Cell> cells,
  2. {Offset start = Offset.zero,
  3. int? width}
)

Optimally draws a batch of cells at the given start position.

The width parameter is used to determine when to move to the next line, and if not provided, it defaults to the terminal width.

This method is more efficient than calling draw multiple times, and can reduce the number of ANSI escape sequences written to the terminal.

Implementation

void drawBatch(
  Iterable<Cell> cells, {
  Offset start = Offset.zero,
  int? width,
}) {
  var Offset(:x, :y) = start;
  width ??= size.$1;

  for (final cell in cells) {
    draw(x, y, cell);

    if (++x >= width) {
      x = 0;
      y++;
    }
  }
}