maxLength property

int? maxLength
final

The limit on the number of user-perceived characters that this formatter will allow.

The value must be null or greater than zero. If it is null or -1, then no limit is enforced.

Characters

For a specific definition of what is considered a character, see the characters package on Pub, which is what Flutter uses to delineate characters. In general, even complex characters like surrogate pairs and extended grapheme clusters are correctly interpreted by Flutter as each being a single user-perceived character.

For instance, the character "ö" can be represented as '\u{006F}\u{0308}', which is the letter "o" followed by a composed diaeresis "¨", or it can be represented as '\u{00F6}', which is the Unicode scalar value "LATIN SMALL LETTER O WITH DIAERESIS". It will be counted as a single character in both cases.

Similarly, some emoji are represented by multiple scalar values. The Unicode "THUMBS UP SIGN + MEDIUM SKIN TONE MODIFIER", "👍🏽"is counted as a single character, even though it is a combination of two Unicode scalar values, '\u{1F44D}\u{1F3FD}'.

Composing text behaviors

There is no guarantee for the final value before the composing ends. So while the value is composing, the constraint of maxLength will be temporary lifted until the composing ends.

In addition, if the current value already reached the maxLength, composing is not allowed.

Implementation

final int? maxLength;