在颤动文本字段光标位置

问题描述 投票:0回答:1

在 flutter 中我有一个文本字段。现在假设用户类型

2+2+2+2+2+2+2+2+2
现在他点击左边第二个“2”并继续输入“3”,文本变大并向右移动,在某些时候我的光标隐藏到右侧。

如果您在计算器应用程序中看到文本向右增长,但光标出现并停在最右端,现在您输入的任何值文本都会向左增长。

有什么办法可以解决这个问题吗..

谢谢

flutter flutter-textformfield flutter-textinputfield
1个回答
0
投票

试试这个!

TextField(
  controller: _textController,
  textAlign: TextAlign.right,
  decoration: InputDecoration(
    border: OutlineInputBorder(),
  ),
  onChanged: (text) {
    _textController.selection = TextSelection.fromPosition(
      TextPosition(offset: _textController.text.length)
    );
  },
)
© www.soinside.com 2019 - 2024. All rights reserved.