Flutter textfield Flutter RTL cursor position problem n-1

Viewed 195

I don't know if the problem is old but I tried all ways to find a solution without success. the problem when select letter n in input field the cursor jump to n-1 the problem shown in video included , problem in rtl only

The link contains the code and a video of the problem.

the code : link here

the video : link here

1 Answers

I think this because of some characters is encoded as 2 to 4 bytes.

Anyway this snippet can do the trick

TextField(
     onTap: (){
          if(controller.selection == TextSelection.fromPosition(TextPosition(offset: controller.text.length -1))){
             setState(() {
                 controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length));
             });
           }
     },
     controller: controller,
     ...
);
Related