Search code examples
androidiosflutterdartflutter-textformfield

Flutter TextFormField doesn't move caret behind a 'Ç' or 'ç' input


I have this strange behavior throughout all TextFormField widgets in my app that given a Ç or ç input the caret will move back in front of the Ç/ç instead of behind it (observed on Android and iOS). On top of that strange behavior, if I was to insert a new letter, that new letter wouldn't be placed in front of the Ç/ç (as one might assume b/c of the caret), no, it overwrites the Ç/ç in a strange way forming a mix of two letters as if the application didn't know that there's actually a letter already in place. Please check the attached pictures.

I can confirm that this is not a font issue nor an UTF one. The font is capable of displaying a cedilla c, and building a new flutter app with just a TextFormField will not reproduce this issue. So, I've got to be missing something.

I am using a pretty much basic default TextFormField without a custom TextEditingController. I do not want to instantiate a custom TextEditingController for each TextFormField in order to pass a workaround to it (like checking for Ç/ç and moving the caret behind it) b/c as mentioned I know that the default TextFormField works just fine with cedilla c. I hope somebody knows about maybe some config issue or whatnot.

Here's an example of a TextFormField that runs into this behavior:

          TextFormField(
        decoration: const InputDecoration(labelText: 'Name it'),
        validator: (value) {
          if (value!.isEmpty) {
            return 'Name is missing';
          }
          // case: name already exists
          final check = context.read<BookState>().when((books) {
            if (books.any((e) => e.name == value)) {
              return 'Name already exists';
            }
          }, empty: () => null);
          // case: all good
          return check;
        },
        onSaved: (value) => bookName = value!,
      )

caret immediately placed in front of ç resulting in an odd overwriting


Solution

  • I recently updated the flutter sdk as well as some of my dependencies for a new release. The problem is resolved since then without having actually touched the TextFormField widgets. I guess it was a bug in a dependency. google_fonts could be a candidate which received a major version upgrade ...