stringAmountToDouble static method

double stringAmountToDouble(
  1. String amount,
  2. int decimals
)

Converts an amount string (in smallest units) to a decimal number. For example, stringAmountToDouble('10000000', 6) returns 10.0.

Implementation

static double stringAmountToDouble(String amount, int decimals) {
  final bigIntValue = BigInt.parse(amount);
  final factor = BigInt.from(10).pow(decimals);
  return bigIntValue / factor;
}