2

There is a bug in Flutter while using RTL (Right To Left) TextField. If we click on (A), the cursor will stop at B, one before the end of the text, and we can't edit the last character! I created this issue and I hope Flutter people see it and fix it

enter image description here

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210

1 Answers1

5

I solve this bug ..

in your TextField you should use controller and onTab function write

if (textController.selection ==
                            TextSelection.fromPosition(TextPosition(
                                offset:
                                    textController.text.length -
                                        1))) {
                          textController.selection =
                              TextSelection.fromPosition(TextPosition(
                                  offset: textController.text.length));
                        }

full example like

   TextField(
                      textAlign: TextAlign.right,
                      textDirection: TextDirection.rtl,
                      controller:textController,
                      maxLength: 10,
                      onTap: () {
                        if (textController.selection ==
                            TextSelection.fromPosition(TextPosition(
                                offset:
                                    textController.text.length -
                                        1))) {
                          textController.selection =
                              TextSelection.fromPosition(TextPosition(
                                  offset:textController.text.length));
                        }
                      },
                      onChanged: (text) {  },
             );