LengthLimitingTextInputFormatter class

A TextInputFormatter that prevents the insertion of more characters (currently defined as Unicode scalar values) than allowed.

Since this formatter only prevents new characters from being added to the text, it preserves the existing TextEditingValue.selection.

  • maxLength, which discusses the precise meaning of "number of characters" and how it may differ from the intuitive meaning.


LengthLimitingTextInputFormatter(int maxLength)
Creates a formatter that prevents the insertion of more characters than a limit. [...]


maxLength int
The limit on the number of characters (i.e. Unicode scalar values) this formatter will allow. [...]
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


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. [...]
@pragma('vm:entry-point'), inherited
toString() String
Returns a string representation of this object.


operator ==(dynamic other) bool
The equality operator. [...]