mask_input_formatter 0.0.3 mask_input_formatter: ^0.0.3 copied to clipboard
TextInputFormatter for TextField and TextFormField which format the input by a given mask.
mask_input_formatter #
The package provides TextInputFormatter for TextField and TextFormField which format the input by a given mask.
Example #
Check 'example' folder for code sample
Usage #
- Follow the install guide
- Importing the library:
import 'package:mask_input_formatter/mask_input_formatter.dart';
- Create a mask formatter:
MaskInputFormatter myFormatter = MaskInputFormatter(mask: '(AA) #####');
- Set with TextField/TextFormField:
TextFormField(
inputFormatters: [myFormatter],
decoration: InputDecoration(
hintText: "(AB) 12345",
)
) // TextFormField
Result #
// Input --> JK75757
// Output --> (JK) 75757 set formatted text on TextField
Other Mask #
You can use the mask whatever you defined in formatter:
MaskInputFormatter dateFormatter = MaskInputFormatter(mask: '##/##/####');
// --> 26/05/2021
MaskInputFormatter phoneFormatter = MaskInputFormatter(mask: '+# (###) ###-####');
// --> +1 (234) 567-8901
MaskInputFormatter numberFormatter = MaskInputFormatter(mask: 'AAA-###', textAllCaps: true);
// --> XYZ-789
Note #
In last example. --> (AAA-###)
- 'A' character will allow only letters from A-Z.
- '#' character will allow only numbers.
- And other characters and symbols will be added as mask.
Contributing #
Suggestions and Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Developer Team: #
Amjad Jamali & his team members (Kamran Khan, Hina Hussain, Faiza Farooqui) 🎉