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.

flutter_image

Example #

Check 'example' folder for code sample

mask_example

Usage #

  1. Follow the install guide
  2. Importing the library:
import 'package:mask_input_formatter/mask_input_formatter.dart';
  1. Create a mask formatter:
MaskInputFormatter myFormatter =  MaskInputFormatter(mask: '(AA) #####');
  1. 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) 🎉

License #

MIT

11
likes
130
pub points
81%
popularity

Publisher

amjadjamali06.blogspot.com

TextInputFormatter for TextField and TextFormField which format the input by a given mask.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on mask_input_formatter