Flutter 颤振文本带背景覆盖光标的字段文本
“我的文本”字段中的文本具有背景。但是背景覆盖了光标。这个问题有解决办法吗?这可能是一个错误-光标不应该落在文本的背景后面。下面是文本字段的一个示例:Flutter 颤振文本带背景覆盖光标的字段文本,flutter,textfield,Flutter,Textfield,“我的文本”字段中的文本具有背景。但是背景覆盖了光标。这个问题有解决办法吗?这可能是一个错误-光标不应该落在文本的背景后面。下面是文本字段的一个示例: TextField( autofocus: true, keyboardType: TextInputType.multiline, maxLines: null, cursorColor: Colors
TextField(
autofocus: true,
keyboardType: TextInputType.multiline,
maxLines: null,
cursorColor: Colors.white,
cursorWidth: 3.0,
textInputAction: TextInputAction.done,
style: TextStyle(
color: Colors.black,
background: Paint()
..strokeWidth = 30.0
..color = Colors.white
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round),
);
我认为在
TextField
中使用背景色的方法是使用装饰。大致如下:
TextField(
decoration: InputDecoration(
fillColor: Colors.red,
filled: true,
border: OutlineInputBorder()),
autofocus: true,
keyboardType: TextInputType.multiline,
maxLines: null,
cursorColor: Colors.blue,
cursorWidth: 3.0,
textInputAction: TextInputAction.done,
style: TextStyle(
color: Colors.black,
),
),
谢谢你的回复。但是这个文本字段没有达到我上面发布的文本字段的效果。无论输入的文本是否填充文本字段,您的文本字段都会创建一个完全填充颜色的文本字段窗口。另一方面,在我的文本字段中,颜色与文本相耦合。例如,如果没有文本,则其后面没有颜色。或者,如果只有几个字符,背景只在这几个字符后面。我应该将其报告为bug吗?@CyrusG yes肯定会将其报告为bug