In Flutter TextField when I have set the text directrion as 'Right to Left" , some symbols setting into beginning of the line

Viewed 1370

I wanted to make a simple calculator using Flutter so in the TextField, I have set the TextDirection as Right to Left.

 child: TextField(
            textDirection: TextDirection.rtl,
            style: Theme.of(context).textTheme.title,
            showCursor: true,
            readOnly: true,
            controller: displayController,
            decoration: InputDecoration(
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(5),
                )
            ),
          ),

When I pressed a Raised Button the onPressed method works as this,

void digitHandler(String char) { displayController.text=displayController.text+char; }

This String char parameter changes according to the button.

But when I press the '.' symbol the cursor moves into the beginning of that line.

In here I have pressed 5,6 and then dot(.) accordingly. But it displays ".56":

In here I have pressed 5,6 and then dot(.) accordingly. But it displays ".56"

Nothing wrong with the Button onPressed Method and nothing wrong with the TextField Widget.

2 Answers

I am not sure why is that happening. If you are building a calculator and want a display, then you can just use a Text widget and add your text/number to the state accordingly.

Yes. Its kind of bug. You can remove textDirection and try textAlign: TextAlign.right

Related