toUnit method

BigInt toUnit(
  1. String amount, {
  2. bool enforceMaxDecimals = true,
})

Converts a human-readable amount string to its base unit representation.

Example: "1.23"123000000n (with 8 decimals).

enforceMaxDecimals If true, throws an exception when the input amount has more fractional digits than the allowed number of decimals.

Example: For decimals = 2, "1.234" would trigger an exception.

Implementation

BigInt toUnit(String amount, {bool enforceMaxDecimals = true}) {
  return AmountConverterUtils.toUnit(
      amount: amount,
      decimals: decimals,
      enforceMaxDecimals: enforceMaxDecimals);
}