Arithmetic Operations
MultiplyByFixed
final kr = Currency.create('KR', 0);
final amount = Money.parseWithCurrency('100', kr, pattern: 'S0');
final halfish = amount.multiplyByFixed(Fixed.parse('0.4', ));
expect(halfish, equals(Money.fromIntWithCurrency(40, kr)));
expect(halfish.decimalDigits, equals(0));Multiply by num (double or int)
/// Create the KR currency with 0 decimal digits.
final kr = Currency.create('KR', 0);
/// parse '100' to get a Money storing KR100.
final amount = Money.parseWithCurrency('100', kr, pattern: 'S0');
/// Multiply by 0.4 to get KR40
final halfish = amount * 0.4;
expect(halfish, equals(Money.fromIntWithCurrency(40, kr)));
/// scale of the results is 0 as dictated by the Currency.
expect(halfish.decimalDigits, equals(0));Last updated
Was this helpful?