flutter_masked_text
Masked text input for flutter.
Install
Follow this GUIDE
Usage
Import the library
MaskedText
Create your mask controller:
Set controller to your text field:
This is the result:
X
Mask Options
In mask, you can use the following characters:
0
: accept numbersA
: accept letters@
: accept numbers and letters*
: accept any character
Initial Value
To start a mask with initial value, just use text
property on constructor:
Update text programaticaly
If you want to set new text after controller initiatialization, use the updateText
method:
Using custom translators
If you want to use your custom regex to allow values, you can pass a custom translation dictionary:
If you want to use default translator but override some of then, just get base from getDefaultTranslator
and override what you want (here is a sample for obfuscated credit card):
Change the mask in runtime
You can use the updateMask
method to change the mask after the controller was created.
Money Mask
To use money mask, create a MoneyMaskedTextController:
Decimal and Thousand separator
It's possible to customize decimal
and thousand
separators:
Set value programaticaly
To set value programaticaly, use updateValue
:
Get double value
To get the number value from masked text, use the numberValue
property:
Using decoration symbols
You can use currency symbols if you want:
Using default TextEditingController
The MaskedTextController and MoneyMaskedTextController extends TextEditingController. You can use all default native methods from this class.
TODO
- [x] Custom translations
- [x] Money Mask
- [ ] Raw Text Widget
- [ ] Default Pre-Sets like CPF, CNPJ, Date, Credit Card, etc...