writeText method
Implementation
void writeText(int x, int y, String text,
{Style style = Style.none, int? maxWidth}) {
if (y < 0 || y >= height) return;
var cursor = x;
final limit = maxWidth != null ? x + maxWidth : width;
final runes = text.runes;
for (final r in runes) {
if (cursor >= limit || cursor >= width) break;
if (r == 10 || r == 13) continue;
final w = charWidth(r);
if (w == 0) continue;
if (cursor + w > limit || cursor + w > width) {
if (cursor < limit) setChar(cursor, y, ' ', style: style);
break;
}
setChar(cursor, y, String.fromCharCode(r), style: style, width: w);
cursor += w;
}
}