Money.fromDecimal constructor
Creates a Money from a Decimal
amount
.
The amount
's decimal digits are adjusted
to match the currency selected via isoCode
.
If isoCode
isn't a valid currency then an UnknownCurrencyException
is thrown.
Implementation
factory Money.fromDecimal(Decimal amount,
{required String isoCode, int? decimalDigits}) {
final currency = Currencies().find(isoCode);
if (currency == null) {
throw UnknownCurrencyException(isoCode);
}
return Money.fromDecimalWithCurrency(amount, currency,
decimalDigits: decimalDigits);
}