EtherAmount.fromUnitAndValue constructor
- @Deprecated('Please use fromInt, fromBigInt or fromBase10String.')
- 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.
Implementation
@Deprecated(
'Please use fromInt, fromBigInt or fromBase10String.',
)
factory EtherAmount.fromUnitAndValue(EtherUnit unit, dynamic amount) {
BigInt parsedAmount;
if (amount is BigInt) {
parsedAmount = amount;
} else if (amount is int) {
parsedAmount = BigInt.from(amount);
} else if (amount is String) {
parsedAmount = BigInt.parse(amount);
} else {
throw ArgumentError('Invalid type, must be BigInt, string or int');
}
return EtherAmount.inWei(parsedAmount * _factors[unit]!);
}