-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Input Mask Right to Left #33
Comments
I also need this for currency masking. For example, if I have a currency mask and I input "1", I expect the mask to be applied as |
Any updates on this? |
Still.... |
You can use this code inputFormatters: <TextInputFormatter>[
// _moneyMaskFormatter
TextInputFormatter.withFunction(
(oldValue, newValue) {
String newText = newValue.text
// .replaceAll(MoneyTextFormField._cents, '')
.replaceAll('.', '')
.replaceAll(',', '')
.replaceAll('_', '')
.replaceAll('-', '');
String value = newText;
int cursorPosition = newText.length;
if (newText.isNotEmpty) {
value = _formatCurrency(
double.parse(newText),
);
cursorPosition = value.length;
}
return TextEditingValue(
text: value,
selection: TextSelection.collapsed(
offset: cursorPosition,
),
);
}),
], String _formatCurrency(num value) {
ArgumentError.checkNotNull(value, 'value');
value = value / 100;
return NumberFormat.currency(
// customPattern: '###.###,##',
customPattern: '###,###.##',
// locale: 'pt_BR',
).format(value);
} |
I need this feature as well |
I couldn't quite understand what you want so I can't implement :/ - if someone can explain it better, I can worry about implementing what I'm currently working on the financial mask |
this tip was very useful, thank you |
Add an option to apply the mask from right to left in the input.
Example with RL option activated:
Mask
##.###.###-#
Expected Behaviur
17.173.127-2
2.412.412-5
Normal Behaviur (how it works now)
17.173.127-2
24.124.125
The text was updated successfully, but these errors were encountered: