prefixLines function
Prefixes every non-blank line of chunk with label.
label arrives already padded and coloured — ANSI escapes count toward
string length, so padding here would misalign every prefix.
Returns the lines rather than printing them, so the caller decides where they go and a test can look at them.
Implementation
List<String> prefixLines(String chunk, String label) {
return [
for (final line in chunk.split('\n'))
if (lastFrame(line) case final frame
when frame.isNotEmpty && !isUnfinished(frame))
'$label | $frame',
];
}