encodeValue method

  1. @override
Uint8List encodeValue(
  1. num x
)
override

Encode the value. This needs to be public because it is used by encodeValue() from different types. @internal

Implementation

@override
Uint8List encodeValue(x) {
  // const buf = Buffer.allocUnsafe(this._bits / 8);
  var length = (_bits / 8).ceil();
  var byte = ByteData(length);

  _bits == 32
      ? byte.setFloat32(0, x is! double ? x.toDouble() : x, Endian.little)
      : byte.setFloat64(0, x is! double ? x.toDouble() : x, Endian.little);
  return byte.buffer.asUint8List();
}