Fixed.fromDecimal constructor

Fixed.fromDecimal(
  1. Decimal amount, {
  2. int scale = 2,
})

Creates a fixed scale decimal from amount with the given scale.

scale defaults to 2 if not passed.

Implementation

Fixed.fromDecimal(Decimal amount, {this.scale = 2}) {
  _checkScale(scale);
  value = _rescale(
    amount,
    existingScale: amount.hasFinitePrecision ? amount.scale : null,
    targetScale: scale,
  );
}