MaxLengthEnforcement enum Null safety

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.

MaxLengthEnforcement()
enforced → const MaxLengthEnforcement

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

MaxLengthEnforcement()
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.

MaxLengthEnforcement()

Properties

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

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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.
[none, enforced, truncateAfterCompositionEnds]