flutter - 在文本表单字段的文本末尾添加不可编辑的字符串
问题描述
当用户在文本表单字段中输入值时,我试图在末尾添加字符串值。我可以添加值作为后缀,但我想将值添加到非常接近文本表单字段输入的位置。
TextFormField(
style: TextStyle(
color: Colors.black,
fontSize: 20),
keyboardType:
TextInputType.number,
controller:
loanTenureController,
focusNode: loanTenureFocus,
cursorColor: Colors.blueGrey,
inputFormatters: [
WhitelistingTextInputFormatter(
RegExp("[0-9]")),
LengthLimitingTextInputFormatter(
2)
],
decoration: InputDecoration(
border: InputBorder.none,
labelText: S
.of(context)
.loanTenureInYears,
labelStyle: TextStyle(
fontSize: 18,
color: getColor(
snapshot.data,
loanTenureFocus,
"loanTenure"),
),
),
),
```[![enter image description here][1]][1]
i want like this field
[![在此处输入图像描述][1]][1]
解决方案
然后将您的文本字段放在表单小部件中:
Form(
onChanged: () {
_textEditingController.text = _textEditingController.text +
suffixThatYouWant.toString()
}
),
推荐阅读
- javascript - 带有 Javascript 类和构造函数的计时器代码
- php - SQL 使用 NOT IN 的子查询结果
- javascript - 转换温度但华氏值不返回
- html - 文件预览显示 Angular 9 中最后选择的文件
- python - apache 服务器正在运行但 django 站点未加载(使用 wsgi)
- python - Numpy中傅里叶变换的可逆性问题
- php - SQL 查询获取主选择查询的行排名或位置
- performance - 单个图表中的两个指标 applicationinsights
- angular - TypeError:无法读取未定义的属性“自动完成”
- ansible - Ansible 滚动重启多集群环境