toBytes static method

BuBytes toBytes(
  1. double value, {
  2. Endian byteOrder = Endian.big,
})

Converts a float value to bytes.

  • value : The float value to encode.
  • byteOrder (optional): The byte order for encoding. Defaults to big endian.

Implementation

static BuBytes toBytes(double value, {Endian byteOrder = Endian.big}) {
  final ByteData byteData = ByteData(4);
  byteData.setFloat32(0, value, byteOrder);
  return BuBytes.unsafeMutable(byteData.buffer.asUint8List());
}