EtherAmount class

Utility class to easily convert amounts of Ether into different units of quantities.

Constructors

EtherAmount.fromBase10String(EtherUnit unit, String amount)
Constructs an amount of Ether by a unit and its amount.
factory
EtherAmount.fromBigInt(EtherUnit unit, BigInt amount)
Constructs an amount of Ether by a unit and its amount.
factory
EtherAmount.fromInt(EtherUnit unit, int amount)
Constructs an amount of Ether by a unit and its amount.
factory
EtherAmount.fromUnitAndValue(EtherUnit unit, dynamic amount)
Constructs an amount of Ether by a unit and its amount. amount can either be a base10 string, an int or a BigInt.
factory
EtherAmount.inWei(BigInt _value)
const
EtherAmount.zero()

Properties

getInEther BigInt
no setter
getInWei BigInt
no setter
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getValueInUnit(EtherUnit unit) double
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 ether in a human-readable format, it should not be used for anything else.
getValueInUnitBI(EtherUnit unit) BigInt
Gets the value of this amount in the specified unit as a whole number. WARNING: For all units except for EtherUnit.wei, this method will discard the remainder occurring in the division, making it unsuitable for calculations or storage. You should store and process amounts of ether by using a BigInt storing the amount in wei.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(dynamic other) bool
The equality operator.
override