currency method
Formats the value in a currency format.
If code and separator are not provided, the formatter will use
Separator.commaAndDot by default.
Implementation
Formatter currency({
String? code, // USD, BRL, etc
String? leading,
String? trailing,
int? mantissa, // decimal places
int? maxLength,
bool? usePadding,
Separator? separator,
ValueChanged<num>? onChanged,
}) {
V? get<V>(String key) {
if (currencyConfigs[code]?[key] case V it) return it;
return null;
}
return addFormatter(
CurrencyInputFormatter(
thousandSeparator: separator?.thousandSeparator ?? get('separator'),
mantissaLength: mantissa ?? get('mantissa') ?? 2,
leadingSymbol: leading ?? get('leading') ?? '',
trailingSymbol: trailing ?? get('trailing') ?? '',
useSymbolPadding: usePadding ?? get('padding') ?? false,
maxTextLength: maxLength,
onValueChange: onChanged,
),
);
}