MoneyMaskedTextController constructor
MoneyMaskedTextController({})
Implementation
MoneyMaskedTextController({
double? initialValue,
this.decimalSeparator = ',',
this.thousandSeparator = '.',
this.rightSymbol = '',
this.leftSymbol = '',
this.precision = 2,
}) {
_validateConfig();
_shouldApplyTheMask = true;
addListener(() {
if (_shouldApplyTheMask) {
var parts = _getOnlyNumbers(text).split('').toList(growable: true);
if (parts.isNotEmpty) {
// Ensures that the list of parts contains the minimum amount of
// characters to fit the precision
if (parts.length < precision + 1) {
parts = [...List.filled(precision, '0'), ...parts];
}
parts.insert(parts.length - precision, '.');
updateValue(double.parse(parts.join()));
}
}
});
updateValue(initialValue);
}