MaxLengthEnforcement enum

Mechanisms for enforcing maximum length limits.

This is used by TextField to specify how the TextField.maxLength should be applied.

MaxLengthEnforcement.enforced versus

MaxLengthEnforcement.truncateAfterCompositionEnds

Both MaxLengthEnforcement.enforced and MaxLengthEnforcement.truncateAfterCompositionEnds make sure the final length of the text does not exceed the max length specified. The difference is that MaxLengthEnforcement.enforced truncates all text while MaxLengthEnforcement.truncateAfterCompositionEnds allows composing text to exceed the limit. Allowing this "placeholder" composing text to exceed the limit may provide a better user experience on some platforms for entering ideographic characters (e.g. CJK characters) via composing on phonetic keyboards.

Some input methods (Gboard on Android for example) initiate text composition even for Latin characters, in which case the best experience may be to truncate those composing characters with MaxLengthEnforcement.enforced.

In fields that strictly support only a small subset of characters, such as verification code fields, MaxLengthEnforcement.enforced may provide the best experience.

See also:

Inheritance

Constructors

MaxLengthEnforcement()
const

Values

none → const MaxLengthEnforcement

No enforcement applied to the editing value. It's possible to exceed the max length.

enforced → const MaxLengthEnforcement

Keep the length of the text input from exceeding the max length even when the text has an unfinished composing region.

truncateAfterCompositionEnds → const MaxLengthEnforcement

Users can still input text if the current value is composing even after reaching the max length limit. After composing ends, the value will be truncated.

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Constants

values → const List<MaxLengthEnforcement>
A constant List of the values in this enum, in order of their declaration.