vishnu kumar
vishnu kumar

Reputation: 63

In flutter text field cursor position

In flutter I have a text field. now let say user types 2+2+2+2+2+2+2+2+2 and now he click on let say 2nd '2' from left and keeps typing '3' the text grows and moves to right and at some point my cursor goes hidden to right.

if you see in calculator app the text grows to right but the cursor comes and stop at extreme right end and now any value u type text grows to left.

Is there any way to handle this..

Thanks

Upvotes: 0

Views: 77

Answers (1)

Shoua Ul Qammar
Shoua Ul Qammar

Reputation: 233

try this !

TextField(
  controller: _textController,
  textAlign: TextAlign.right,
  decoration: InputDecoration(
    border: OutlineInputBorder(),
  ),
  onChanged: (text) {
    _textController.selection = TextSelection.fromPosition(
      TextPosition(offset: _textController.text.length)
    );
  },
)

Upvotes: 0

Related Questions