updateDimensions method

void updateDimensions(
  1. int width,
  2. int height
)

Updates the screen buffer dimensions to accommodate the new size.

If the new dimensions are larger than current, expands the buffer and fills new areas with empty cells. Smaller dimensions are ignored to prevent data loss.

width: New minimum width for the buffer height: New minimum height for the buffer

Implementation

void updateDimensions(int width, int height) {
  if (this.width == width && this.height == height) return;

  this.width = max(width, this.width);
  this.height = max(height, this.height);

  _screenBuffer = List.generate(
    this.height,
    (_) => List.filled(this.width, BufferCell(char: ' ')),
  );

  _previousFrame = List.generate(
    this.height,
    (_) => List.filled(this.width, BufferCell(char: '')),
  );
}