Search packages, repositories and app categories

GitHub repositoryamjadjamali06/mask_input_formatter

mask_input_formatter

amjadjamali06/mask_input_formatter open-source repository details.

mask_input_formatter project cover
Stars
8
Forks
0
Last push (UTC)
Aug 5, 2021
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

mask_input_formatter

pub package likes popularity pub points Platform License

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


Demo

Usage

  1. Add dependency.

Run this command:

With Flutter:

$ flutter pub add mask_input_formatter

or add following package in your pubspec.yaml file inside the dependencies: section.

dependencies:
  mask_input_formatter: ^0.0.3
  1. 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

Check example folder for code sample

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 & team members ( Kamran Khan, Hina Hussain, Faiza Farooqui ) :tada:

License

Apache 2.0

Amjad Jamali GitHub avatar
GitHub author

Amjad Jamali ↗

Android Native And Flutter Developer...

SapphireJamshoro
LanguagesDart

Packages published by this repository

Dependencies used

Dependency list 2 items

  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗