formatUnits static method

String formatUnits(
  1. String value, [
  2. dynamic unit = 'ether'
])

Returns a String representation of value formatted with unit digits (if it is a number) or to the unit specified (if a string).


final oneGwei = "1000000000";
final oneEther = "1000000000000000000";

EthUtils.formatUnits(oneGwei, 0);
// '1000000000'

EthUtils.formatUnits(oneGwei, "gwei");
// '1.0'

EthUtils.formatUnits(oneGwei, 9);
// '1.0'

EthUtils.formatUnits(oneEther);
// '1.0'

EthUtils.formatUnits(oneEther, 18);
// '1.0'

Implementation

external static String formatUnits(String value, [dynamic unit = 'ether']);