The Money class allows you to create a Money instance from a variety of other types:
Each of the variants have a
The recommended method is to used
Money.fromFixed or the `withCurrency` alternative. Using `fromFixed` then allows you to store and transmit your Money amounts without loss of precision.
Moneycan be instantiated by providing the amount in the minor units of the currency (e.g. cents):
// create one (1) australian dollar
Money t1 = Money.fromFixed(Fixed.fromInt(100, scale: 2), code: 'AUD');
Money t2 = Money.parse(r'$1.00', code: 'AUD');
Money t3 = Money.fromFixedWithCurrency(Fixed.fromInt(100, scale: 2),
Money t4 = Money.parse(r'$1.00', currency: CommonCurrencies().aud);
// Create a money value of $5.10 usd from an int
Money fiveDollars = Money.fromInt(510, 'USD');
// Create a money value of ¥25010 from a big int.
Money bigDollars = Money.fromBigInt(BigInt.from(25010), 'JPY');