setFloatAt method

void setFloatAt(
  1. int offset,
  2. int bytes,
  3. double value,
  4. StructEndian endian,
)

Write float with specified endianness

  • offset: The offset to write to
  • bytes: The number of bytes to write
  • value: The float value to write
  • endian: The endianness to use

Implementation

void setFloatAt(int offset, int bytes, double value, StructEndian endian) {
  switch (bytes) {
    case 4:
      setFloat32(offset, value, endian.toEndian());
      break;
    case 8:
      setFloat64(offset, value, endian.toEndian());
      break;
    default:
      throw ArgumentError('Unsupported float size: $bytes bytes');
  }
}