mask_input_formatter 0.0.3 copy "mask_input_formatter: ^0.0.3" to clipboard
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

29
likes
150
points
738
downloads

Publisher

verified publisheramjadjamali06.blogspot.com

Weekly Downloads

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