TextInputFormatter class
A TextInputFormatter can be optionally injected into an EditableText to provide as-you-type validation and formatting of the text being edited.
Text modification should only be applied when text is being committed by the IME and not on text under composition (i.e., only when TextEditingValue.composing is collapsed).
Concrete implementations BlacklistingTextInputFormatter, which removes blacklisted characters upon edit commit, and WhitelistingTextInputFormatter, which only allows entries of whitelisted characters, are provided.
To create custom formatters, extend the TextInputFormatter class and implement the formatEditUpdate method.
See also:
- EditableText on which the formatting apply.
- BlacklistingTextInputFormatter, a provided formatter for blacklisting characters.
- WhitelistingTextInputFormatter, a provided formatter for whitelisting characters.
Constructors
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
formatEditUpdate(
TextEditingValue oldValue, TextEditingValue newValue) → TextEditingValue - Called when text is being typed or cut/copy/pasted in the EditableText. [...]
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
withFunction(
TextInputFormatFunction formatFunction) → TextInputFormatter - A shorthand to creating a custom TextInputFormatter which formats incoming text input changes with the given function.