toEther method

double toEther({
  1. required BigInt fromWei,
  2. int decimals = 18,
})

单位转换: wei -> ether

  • bigInt 有坑: 只有 x/y = double 值是正确的

Implementation

double toEther({
  required BigInt fromWei,
  int decimals = 18, // 转换精度位数: 默认 eth=18
}) {
  /// 换算单位: 10^x 幂
  var unit = BigInt.from(10).pow(decimals);

  /// 转换:
  return fromWei / unit;
}