MaskFunctionTextInputFormatter class

A TextInputFormatter based on the maskFunction formatter, for using in TextFields.

The keys of the filter assign which character in the mask should be replaced, and the values validate the entered character. By default # matches a number, and A matches a letter.

Note: This code is adapted from https://pub.dev/packages/mask_text_input_formatter by Sergey (https://github.com/siqwin).

Implemented types

Constructors

MaskFunctionTextInputFormatter({required MaskFunction maskFunction, Map<String, RegExp>? filter, String? initialText})
Creates an TextInputFormatter based on the maskFunction formatter, for using in TextFields.

Properties

hashCode int
The hash code for this object.
no setterinherited
maskFunction MaskFunction
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clear the masked text of the formatter. Note: You need to call this method if you clear the text of the TextField, because it doesn't call the formatter when it has empty text.
formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) TextEditingValue
Called when text is being typed or cut/copy/pasted in the EditableText.
override
getMask() String?
Get the current mask.
getMaskedText() String
Get the masked text, for example: "+0 (123) 456-78-90".
getUnmaskedText() String
Get unmasked text, for example: "01234567890".
isFill() bool
Check if mask is filled.
maskText(String text) String
Mask the text.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
unmaskText(String text) String
Unmask the text.

Operators

operator ==(Object other) bool
The equality operator.
inherited