MaxLengthEnforcement enum Null safety
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.
- enforced → const MaxLengthEnforcement
Keep the length of the text input from exceeding the max length even when the text has an unfinished composing region.
- none → const MaxLengthEnforcement
No enforcement applied to the editing value. It's possible to exceed the max length.
- 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.
→ const List<
A constant List of the values in this enum, in order of their declaration.