PolyAmount class
Utility class to easily convert amounts of Poly into different units of quantities.
Constructors
- PolyAmount({required num quantity, required dynamic unit})
- PolyAmount.fromUnitAndValue(PolyUnit unit, dynamic amount)
-
Constructs an amount of Poly by a unit and its amount.
amount
can either be a base10 string, an int, or any numerical value.factory - PolyAmount.inNanopoly({required num quantity})
- PolyAmount.zero()
Properties
Methods
-
getValueInUnit(
PolyUnit unit) → num - Gets the value of this amount in the specified unit. WARNING: Due to rounding errors, the return value of this function is not reliable, especially for larger amounts or smaller units. While it can be used to display the amount of poly in a human-readable format, it should not be used for anything else.
-
getValueInUnitBI(
PolyUnit unit) → num - Gets the value of this amount in the specified unit as a whole number. WARNING: For all units except, this method will discard the remainder occurring in the division, making it unsuitable for calculations or storage. You should store and process amounts of poly by using a BigInt storing the amount in nanopoly.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → String -
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
dynamic other) → bool -
The equality operator.
override