symbolRuns function
text cut into its runs of isSymbolRunRune characters and the text
between them, in order: sin then ⁻¹ (symbols) for sin⁻¹. Empty
for an empty text.
Implementation
List<({String text, bool symbols})> symbolRuns(String text) {
final runs = <({String text, bool symbols})>[];
final run = StringBuffer();
bool? current;
for (final rune in text.runes) {
final symbols = isSymbolRunRune(rune);
if (current != null && symbols != current) {
runs.add((text: run.toString(), symbols: current));
run.clear();
}
current = symbols;
run.writeCharCode(rune);
}
if (current != null) runs.add((text: run.toString(), symbols: current));
return runs;
}