decodePackedFixed32 function

List<int> decodePackedFixed32(
  1. List<int> data
)

Decode concatenated fixed32 (4-byte little-endian) integers from data.

The caller has already extracted the raw bytes for the packed field. This function reads 4-byte chunks until all bytes are consumed.

Returns a list of decoded 32-bit unsigned integer values.

Throws a FormatException if the data length is not a multiple of 4.

Implementation

List<int> decodePackedFixed32(List<int> data) {
  if (data.length % 4 != 0) {
    throw FormatException(
      'Packed fixed32 data length must be a multiple of 4, '
      'got ${data.length}',
    );
  }
  List<int> results = [];
  int offset = 0;
  while (offset < data.length) {
    Map<String, int> result = decodeFixed32(data, offset);
    results.add(result['value']!);
    offset += result['bytesRead']!;
  }
  return results;
}