【发布时间】:2020-11-23 04:14:30
【问题描述】:
我已经读过了。 how to make clear button appears when text is enter in TextFormField in flutter 但它不起作用,而且我发现输入文本时文本字段无法识别更改。如果您知道解决方案,如果您告诉我,我将不胜感激。
下面是我的代码:
TextField(
controller: _controller,
onChanged: (String word) {
this.word = word;
_controller.text = word;
},
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
color: Colors.black),
decoration: InputDecoration(
isDense: true,
suffix: _controller.text.length > 0
? Padding(
padding: const EdgeInsetsDirectional.only(
bottom: 2),
child: IconButton(
onPressed: () => _controller.clear(),
icon: Icon(Icons.clear),
iconSize: 25,
color: Colors.black.withOpacity(0.5),
))
: null,
contentPadding:
EdgeInsets.only(left: 8.5, bottom: 3),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black),
),
hintText: "Add text",
hintStyle: TextStyle(
fontSize: 29.0,
color: Colors.black.withOpacity(0.5)),
)),
我想做什么:
【问题讨论】: