Skip to content
pubscout

mask_text_input_formatter

2.9.0, released 3 years ago by an unverified publisher

TextInputFormatter for TextField and TextFormField to format input using a given mask.

WASM-ready
$ flutter pub add mask_text_input_formatter
Source repository

What it does

Provides a TextInputFormatter that automatically formats text input in TextField and TextFormField widgets based on a defined mask string and regular expression filters. It supports both lazy and eager autocompletion modes, allows retrieving unmasked values, and lets you update masks dynamically.

AI-written summary of version 2.9.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to format phone numbers, credit cards, dates, or other structured input in text fields.
  • You need to easily retrieve both the masked and unmasked values from a text field.

Skip it when

  • You require a full form builder solution rather than just an input formatter.

Strengths

  • Easy integration with standard Flutter TextField and TextFormField widgets.
  • Supports dynamic mask updates and lazy/eager autocompletion types.
  • Provides methods to retrieve both masked and unmasked text values easily.

Weaknesses

  • Limited to text formatting via string masks and filters.
  • No built-in comprehensive collection of predefined regional masks (like international phone formats) out of the box.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
var maskFormatter = new MaskTextInputFormatter(
  mask: '+# (###) ###-##-##', 
  filter: { "#": RegExp(r'[0-9]') },
  type: MaskAutoCompletionType.lazy
);

TextField(inputFormatters: [maskFormatter])

Alternatives

Packages that do the same job and could replace mask_text_input_formatter.

Works with

Packages commonly used together with mask_text_input_formatter: ones it builds on, ones built on it, and its own family.