formatLine static method
Format a complete line with optional grouping
Implementation
static HexLine formatLine(List<int> data, int offset, HexConfig config) {
final end = (offset + config.bytesPerLine).clamp(0, data.length);
if (offset >= data.length || offset < 0) {
return HexLine(
offset: offset,
bytes: const [],
hexString: '',
asciiString: '',
);
}
final bytes = data.sublist(offset, end);
final hexParts = <String>[];
final asciiParts = <String>[];
for (int i = 0; i < bytes.length; i++) {
hexParts.add(formatByte(bytes[i]));
asciiParts.add(formatAscii(bytes[i]));
// Add group separator (| between groups)
if (config.groupSize > 0 &&
(i + 1) % config.groupSize == 0 &&
i < bytes.length - 1) {
hexParts.add('|');
}
}
return HexLine(
offset: offset,
bytes: bytes,
hexString: hexParts.join(' '),
asciiString: asciiParts.join(),
);
}