toGwei function

BigInt toGwei(
  1. String wei
)

Implementation

BigInt toGwei(String wei) {
  final decimals = wei.contains('.') ? wei.split('.')[1].length : 0;
  final wei_without_decimals = wei.replaceAll('.', '');
  final val = BigInt.parse(wei_without_decimals);

  final multiplier = BigInt.from(10).pow(9 - decimals);

  return val * multiplier;
}