我使用searchable_dropdown https://pub.dev/packages/searchable_dropdown
当用户触摸输入文本字段时,如何只显示键盘?
所有示例都显示,只要用户单击下拉按钮,键盘就会显示出来。
如果您检查属于该包的searchable_dropdown.dart,则键盘焦点将设置为真。
Widget searchBar() {
return new Container(
child: new Stack(
children: <Widget>[
new TextField(
controller: txtSearch,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(horizontal: 32, vertical: 12)),
autofocus: true,当用户触摸输入文本字段时,如何只显示键盘?
发布于 2021-01-25 20:22:16
在searceable_dropdown.dart中查找searchBar小部件并将自动焦点更改为false不要忘记运行pub get
Widget searchBar() {
return new Container(
child: new Stack(
children: <Widget>[
new TextField(
controller: txtSearch,
decoration: InputDecoration(
contentPadding:
EdgeInsets.symmetric(horizontal: 32, vertical: 12)),
autofocus: false,//Here change from true to false
onChanged: (value) {
_updateShownIndexes(value);
setState(() {});
},
keyboardType: widget.keyboardType,
),
new Positioned(
left: 0,
top: 0,
bottom: 0,
child: new Center(
child: new Icon(
Icons.search,
size: 24,
),
),
),
txtSearch.text.isNotEmpty
? new Positioned(
right: 0,
top: 0,
bottom: 0,
child: new Center(
child: new InkWell(
onTap: () {
_updateShownIndexes('');
setState(() {
txtSearch.text = '';
});
},
borderRadius: BorderRadius.all(Radius.circular(32)),
child: new Container(
width: 32,
height: 32,
child: new Center(
child: new Icon(
Icons.close,
size: 24,
),
),
),
),
),
)
: new Container(),
],
),
);
}发布于 2021-08-10 11:16:27
我找到了解决办法。去上searchable_dropdown.dart课。在第871或877行,将出现自动对焦: true。只是转换真正的=>筋膜。关闭项目并重新启动。这会管用的。
https://stackoverflow.com/questions/61426045
复制相似问题