Fixed.fromDecimal constructor

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

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

scale defaults to 16 if not passed.

Implementation

Fixed.fromDecimal(Decimal amount, {this.scale = 16}) {
  _checkScale(scale);
  minorUnits = _rescale(
    (amount * Decimal.ten.pow(amount.scale).toDecimal()).toBigInt(),
    existingScale: amount.scale,
    targetScale: scale,
  );
}