我遇到了一个问题,就是用 new Expanded()
包装 TextField
。当尝试在 textfield
中搜索某些内容时,它会显示 30px
的底部溢出。以下是我的代码:
Widget build(BuildContext context) {
return new Scaffold(
body:
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(icon: Icon(Icons.search), onPressed: () {
setState(() {
});
}),
new Flexible(
child: new TextField(
onChanged: (String value) {
onchange(value);
},
maxLines: 1,
autocorrect: true,
// decoration: const InputDecoration(helperText: "Search"),
style: new TextStyle(fontSize: 10.0, color: Colors.black),
),
),
_text != null ? IconButton(
icon: Icon(Icons.close), onPressed: (){
}) : new Container(),
IconButton(icon: Icon(Icons.bookmark_border), onPressed: () {}),
],
),
new Expanded(
child: FilstList(searchtext: _text,)
),
],
),
);
}
}
最佳答案
这个问题有两种解决方案。
将
resizeToAvoidBottomPadding: false
添加到您的Scaffold
Scaffold( resizeToAvoidBottomPadding: false, body: ...)
- 将您的
FilstList(searchtext: _text,)
放入scrollableView
(如SingleChildScrollView
或ListView
)
关于flutter - 底部溢出 30px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51972371/