hexView function
String
hexView(
- int startAddress,
- Iterable<
int> data, { - HexRecordFormatter formatter = const DefaultRecordFormatter(),
- String recordSeparator = '\n',
Implementation
String hexView(int startAddress, Iterable<int> data,
{HexRecordFormatter formatter = const DefaultRecordFormatter(),
String recordSeparator = '\n'}) {
final recordLength = formatter.recordLength;
final sb = StringBuffer();
int address;
{
final firstTake = recordLength - (startAddress % recordLength);
final first = data.take(firstTake);
data = data.skip(firstTake);
final record = Record.prefix(startAddress, first, recordLength);
sb.write(formatter.format(record));
address = record.startAddress + recordLength;
}
while (data.length >= recordLength) {
final recordData = data.take(recordLength);
final record = Record(address, recordData.toList());
sb.write(recordSeparator);
sb.write(formatter.format(record));
address = record.startAddress + recordLength;
data = data.skip(recordLength);
}
if (data.isNotEmpty) {
final record = Record.suffix(address, data, recordLength);
sb.write(recordSeparator);
sb.write(formatter.format(record));
}
return sb.toString();
}