Flutter how to get cursor in text field to stop moving to the beginning?

You do not have to do

controller..text = text;

inside onChanged because the controller’s text automatically changes once you connect it to TextField.

The reason is once you set some text to controller, it re-applies the text thus moving the cursor at front.

In your case :

TextField(
    decoration: InputDecoration(
       border: InputBorder.none
    ),
    controller: controller,
    autofocus: true,
    onChanged: (text) {},
    maxLines: 8,
)

should solve the issue.

Leave a Comment