| /// Splits a raw multi-line log string into individual lines without changing |
| /// their content. |
| /// |
| /// Handles both `\n` and `\r\n` line endings. A trailing line break is ignored |
| /// so log blocks ending with a newline do not render an extra empty row. |
| Iterable<String> splitLogLines(String rawLog) sync* { |
| if (rawLog.isEmpty) { |
| return; |
| } |
| |
| final lines = rawLog.split(RegExp(r'\r?\n')); |
| final end = lines.isNotEmpty && lines.last.isEmpty ? lines.length - 1 : lines.length; |
| |
| for (var i = 0; i < end; i++) { |
| yield lines[i]; |
| } |
| } |