getDecimalFixedPointDecoder function

FixedPointDecoder<DecimalFixedPoint> getDecimalFixedPointDecoder(
  1. FixedPointSignedness signedness,
  2. int totalBits,
  3. int decimals, {
  4. FixedPointEndian endian = FixedPointEndian.little,
})

Returns a decoder for DecimalFixedPoint values with the given shape.

Implementation

FixedPointDecoder<DecimalFixedPoint> getDecimalFixedPointDecoder(
  FixedPointSignedness signedness,
  int totalBits,
  int decimals, {
  FixedPointEndian endian = FixedPointEndian.little,
}) {
  _assertValidByteAlignedShape(totalBits);
  if (decimals < 0) throw RangeError.range(decimals, 0, null, 'decimals');
  final byteSize = totalBits ~/ 8;
  return FixedPointDecoder(
    fixedSize: byteSize,
    read: (buffer, offset) {
      _assertReadable(buffer, offset, byteSize);
      final raw = _readRawBigInt(buffer, offset, byteSize, signedness, endian);
      return (
        DecimalFixedPoint(
          raw: raw,
          decimals: decimals,
          signedness: signedness,
          totalBits: totalBits,
        ),
        offset + byteSize,
      );
    },
  );
}