mask_text_input_formatter
v2.9.0The package provides TextInputFormatter for TextField and TextFormField which format the input by a given mask.
Package archive: https://pubdev.letsnova.ru/api/archives/mask_text_input_formatter/2.9.0.tar.gz
dart pub add mask_text_input_formatterReadme
mask_text_input_formatter
The package provides TextInputFormatter for TextField and TextFormField which format the input by a given mask.

Example
Check 'example' folder for code sample

Usage
-
Follow the install guide
-
Import the library:
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
- Create mask formatter:
var maskFormatter = new MaskTextInputFormatter(
mask: '+# (###) ###-##-##',
filter: { "#": RegExp(r'[0-9]') },
type: MaskAutoCompletionType.lazy
);
- Set it to text field:
TextField(inputFormatters: [maskFormatter])
Get value
Get masked text:
print(maskFormatter.getMaskedText()); // -> "+0 (123) 456-78-90"
Get unmasked text:
print(maskFormatter.getUnmaskedText()); // -> 01234567890
Change the mask
You can use the updateMask method to change the mask after the formatter was created:
var textEditingController = TextEditingController(text: "12345678");
var maskFormatter = new MaskTextInputFormatter(mask: '####-####', filter: { "#": RegExp(r'[0-9]') });
TextField(controller: textEditingController, inputFormatters: [maskFormatter]) // -> "1234-5678"
textEditingController.value = maskFormatter.updateMask(mask: "##-##-##-##"); // -> "12-34-56-78"
Changelog
[2.9.0]
Fixed #92
[2.8.0]
Added: type parameter to updateMask method
Fixed #88
[2.7.0]
Fixed #86
[2.6.0]
Fixed #82
Removed deprecated lints
Added eager mask type constructor for shortening
[2.5.0]
Fixed: #70
Added: newValue parameter to updateMask method
[2.4.0]
Fix #70
[2.3.0]
Fix #62
[2.2.0]
Fix eager autocompletion #68
[2.1.0]
Added support for eager autocompletion. Thanks to @jyardin
[2.0.2]
Add analysis_options
[2.0.1]
Fix #52
[2.0.0]
Stable version
[1.2.1] / [2.0.0-nullsafety.2]
Fix bug
[1.2.0] / [2.0.0-nullsafety.1]
Fix some bugs
[2.0.0-nullsafety.0]
Migrate to null safety
[1.1.0]
Added: clear function Added: function to get a current mask Added: functions to mask/unmask some text Updated example app Fixed some bugs
[1.0.7]
Fix clear text bug + test Some docs added
[1.0.6]
Fix bug
[1.0.5]
Minor changes
[1.0.4]
Minor changes
[1.0.3]
Fix paste
[1.0.2]
Update readme.md
[1.0.1]
Added tests Fix some bugs
[1.0.0]
Initial version
