AmountConverter constructor

AmountConverter({
  1. required int decimals,
  2. int? displayPrecision = 8,
})

Creates a converter with the specified decimals and displayPrecision.

Throws AmountConverterException if:

  • decimals is negative or exceeds mask8.
  • displayPrecision is negative.

Implementation

factory AmountConverter({required int decimals, int? displayPrecision = 8}) {
  if (decimals.isNegative || decimals > mask8) {
    throw AmountConverterException(
      'Invalid decimals value: must be between 0 and $mask8.',
    );
  }
  if (displayPrecision != null && displayPrecision.isNegative) {
    throw AmountConverterException(
        "Invalid displayPrecision value: must be non-negative.");
  }
  return AmountConverter._(
      decimals: decimals, displayPrecision: displayPrecision);
}