onChanged property

ValueChanged<String>? onChanged
final

Called when the user initiates a change to the MongolTextField's value: when they have inserted or deleted text.

This callback doesn't run when the MongolTextField's text is changed programmatically, via the MongolTextField's controller. Typically it isn't necessary to be notified of such changes, since they're initiated by the app itself.

To be notified of all changes to the MongolTextField's text, cursor, and selection, one can add a listener to its controller with TextEditingController.addListener.

Handling emojis and other complex characters

It's important to always use characters when dealing with user input text that may contain complex characters. This will ensure that extended grapheme clusters and surrogate pairs are treated as single characters, as they appear to the user.

For example, when finding the length of some user input, use string.characters.length. Do NOT use string.length or even string.runes.length. For the complex character "👨‍👩‍👦", this appears to the user as a single character, and string.characters.length intuitively returns 1. On the other hand, string.length returns 8, and string.runes.length returns 5!

See also:

Implementation

final ValueChanged<String>? onChanged;