convert method
Converts the value of this money to the currency expressed by rate
.to
.
Implementation
Money convert({
required ExchangeRate rate,
}) {
if (rate.to == currency) {
return this;
}
if (rate.from != currency) {
throw ArgumentError(
'The base currency of the rate is different from the currency of this'
' money. Change the rate with one which has the same currency.');
}
return Money(
amount: amount * rate.value,
currency: rate.to,
);
}