Money class
Represents money
Supports +
, -
, /
, *
, %
and all comparison operators, but works only
with instances of the same currency. See CurrencyInfo to exchange
currencies by rate
- Implemented types
Constructors
- Money(int amount, Currency currency)
-
Constructs new money instance
const
- Money.abs(Money target)
-
Returns new Money instance of the same currency with
absolute value of amount
factory
- Money.float(double amount, Currency currency)
-
Converts double to integer which represents amount of the instance
in the smallest unit of the currency
factory
- Money.separated(int integer, int fraction, Currency currency)
-
Accepts main and fractional part of the amount as two integers
factory
Properties
- amount → int
-
Amount of money in the smallest unit of a currency
final
- currency → Currency
-
The currency of money
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isNegative → bool
-
Returns
true
if the amount is <0
no setter - isZero → bool
-
Returns
true
if the amount is0
no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
compareTo(
Money other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDouble(
) → double - Converts money to a double
-
toNumericString(
) → String - Converts money to stringified double
-
toString(
) → String -
Turns the money object to user-friendly string
override
Operators
-
operator %(
int other) → Money - Does euclidean division (mod) of amount of the Money on integer operand and creates new instance
-
operator *(
int other) → Money - Multiplies amount of the Money on integer operand and creates new instance
-
operator +(
Money other) → Money - Adds amount of the second Money operand and creates new instance
-
operator -(
Money other) → Money - Subtracts amount of the second Money operand and creates new instance
-
operator /(
int other) → Money - Divides amount of the Money on integer operand and creates new instance
-
operator <(
Money other) → bool - Compares amounts of two Money instances
-
operator <=(
Money other) → bool - Compares amounts of two Money instances
-
operator ==(
dynamic other) → bool -
The quantity operator
override
-
operator >(
Money other) → bool - Compares amounts of two Money instances
-
operator >=(
Money other) → bool - Compares amounts of two Money instances
Static Properties
- fancyCurrencies ↔ bool
-
Change Money.toString() behavior to use special currency symbols
getter/setter pair
Static Methods
Constants
- zero → const Money
- Constant for zero amount of a Currency.dummy currency