parseSummaryData static method
Extracts SummaryData from a Uint8List of bytes. Each set of summary data is expected to be 106 bytes. The method reads the bytes sequentially and creates a list of SummaryData objects. If the bytes are empty, an empty list is returned. If any error occurs during the process, an error message is printed to the console.
Parameters:
bytesSummaryPsk
A Uint8List containing binary data representing summary information.
Returns: A List
Implementation
static List<SummaryData> parseSummaryData(Uint8List bytesSummaryPsk) {
if (bytesSummaryPsk.isEmpty) {
return [];
}
final List<SummaryData> addressSummary = [];
int index = 0;
try {
while (index + 106 <= bytesSummaryPsk.length) {
final sumData = SummaryData();
sumData.hash = String.fromCharCodes(bytesSummaryPsk.sublist(
index + 1, index + bytesSummaryPsk[index] + 1));
sumData.custom = String.fromCharCodes(bytesSummaryPsk.sublist(
index + 42, index + 42 + bytesSummaryPsk[index + 41]));
sumData.balance = NosoMath().bigIntToDouble(
fromPsk: bytesSummaryPsk.sublist(index + 82, index + 90));
final scoreArray = bytesSummaryPsk.sublist(index + 91, index + 98);
if (!scoreArray.every((element) => element == 0)) {
sumData.score = NosoMath().bigIntToInt(fromPsk: scoreArray);
}
final lastOpArray = bytesSummaryPsk.sublist(index + 99, index + 106);
if (!lastOpArray.every((element) => element == 0)) {
// sumData.lastOP = lastOpArray;
}
addressSummary.add(sumData);
index += 106;
}
} catch (e) {
print('Error reading Summary: $e');
}
return addressSummary;
}