drawText method

void drawText(
  1. int x,
  2. int y,
  3. String text, [
  4. Color? foreground,
  5. Color? background,
])

Draws the string of characters in text starting at column x, row y of this Terminal using the given foreground and background Colors (or default colors). The text will be truncated if it runs beyond the bounds of the terminal.

Implementation

void drawText(int x, int y, String text,
    [Color? foreground, Color? background]) {
  foreground ??= this.foreground;
  background ??= this.background;

  for (var i = 0; i < text.length; i++) {
    if (x + i >= width) break;
    drawChar(
        x + i, y, Char.create(text.codeUnits[i], foreground, background));
  }
}