writeStringBatch method

  1. @override
int writeStringBatch(
  1. int x,
  2. int y,
  3. String text,
  4. TextStyle? style,
)
override

Writes a string of characters starting at (x, y) with the given style, advancing the cursor by charWidth per character.

Unlike calling writeStyled per character, this checks row bounds once and silently clips characters that fall outside the column range.

Returns the total width advance (sum of charWidth for all characters).

Implementation

@override
int writeStringBatch(int x, int y, String text, TextStyle? style) {
  int cx = x;
  for (int i = 0; i < text.length; i++) {
    final String ch = text[i];
    writeStyled(cx, y, ch, style);
    cx += charWidth(ch.codeUnitAt(0));
  }
  return cx - x;
}