AmountConverter constructor
Creates a converter with the specified decimals and displayPrecision.
Throws AmountConverterException if:
decimalsis negative or exceeds BinaryOps.mask8.displayPrecisionis negative.
Implementation
factory AmountConverter({required int decimals, int? displayPrecision = 8}) {
if (decimals.isNegative || decimals > BinaryOps.mask8) {
throw AmountConverterException(
'Invalid decimals value: must be between 0 and ${BinaryOps.mask8}.',
);
}
if (displayPrecision != null && displayPrecision.isNegative) {
throw AmountConverterException(
"Invalid displayPrecision value: must be non-negative.",
);
}
return AmountConverter._(
decimals: decimals,
displayPrecision: displayPrecision,
);
}