ansiToPlainText function
Converts ANSI/ASCII escaped terminal output into plain display text.
This applies the same control-sequence normalization used by ansiToTextSpan but strips all formatting sequences so callers can search/display only the rendered text content.
Implementation
String ansiToPlainText(String source) {
source = _normalizeControlChars(source);
source = _stripNonSgrCsi(source);
final sgr = RegExp(r'(\x1B|\u001B)\[([0-9;]*)m');
return source.replaceAll(sgr, '');
}