Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Today, we will learn how to format our input text of textFormField with the help of mask_text_input_formatter.
Introduction:-
What is mask_text_input_formatter?
The “mask_text_input_formatter” is one of the many Flutter packages available in the Flutter dev library. The package provides the format for TextField and TextFormField and can mold the input text into the prescribed mask or format.
Implementation:-
Let’s put a text field in our Flutter app and mask the input with the “mask_text_input_formatter” widget.
Step 1:- Add the package dependency
In order to use the mask_text_input_formatter, firstly we need to add this dependence in our Flutter project’s pubspec.yaml file.
Step 2:- Import the package in main.dart file
Next, to use the package we need to import the mask_text_input_formatter package in main.dart file.
After Importing the above package into our main.dart, our code should look like this:-
Now, after importing the above package into our main.dart file we will be able to access the predefined method of mask_text_input_formatter MaskTextInputFormatter().
Step 3:- Make the Format for Text
Finally, we just have to manually design the required text format with the mask parameter of the MaskTextInputFormatter method like this :
Now, we only need to put this format inside the inputFormatter parameter of TextFormField and add the TextFormField to our widget tree.
Step 4:- Output
Finally, we will be able to see the output of these steps. You can also use other formats for formating your input text as mentioned above.
Complete Code:-
Here is the complete code for the above output.
Conclusion
Now we are done with formatting our text using mask_text_input_formatter in Flutter. With this, our textFormField will be able to format the data automatically like:-
For more interesting blogs check out here – https://mobikul.com/blog/
References
https://pub.dev/packages/mask_text_input_formatter
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.