flutter - Flutter TextField 文本与背景覆盖光标
问题描述
我的 TextField 中的文本有背景。但是背景覆盖了光标。这个问题有解决方案吗?这可能是一个错误 - 光标不应落在文本背景的后面。下面是 TextField 的示例:
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),
);
解决方案
我认为在 a 中使用背景颜色的方法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,
),
),
推荐阅读
- python - 我们如何根据元类中 init 传递的属性来改变属性
- java - 如何在不重复请求的情况下使用 Google Places API 获取某种类型的 Lat Longs 列表?
- git - git name-rev 有什么作用?
- java - 如何打印getter String而不将null作为输出?
- python - ValueError:使用 PIL 解包的值太多(预期为 3)
- java - 从 Android 调用邮件 PHP 文件不起作用
- r - 在 RStudio 中开始一个新项目时,Blogdown 给出了一个 gsub 缺少 ')' 错误
- python-3.x - 如何从 Python Pandas 字符串中解析一个字符?
- php - 如果为空,Laravel 增量表
- python - 如何在不循环的情况下对多列(包括结果列)调用应用