首页 文章

如何将SearchView放在ListView之上?

提问于
浏览
0

我是新手,我试图在ListView上堆叠一个searchView . 我会看起来像这样:

enter image description here

我不知道如何在flutter上实现这个布局,我尝试使用一个列(崩溃了应用程序),使用了一个堆栈(它重叠了小部件),我终于尝试在第一个项目中添加一个搜索小部件ListView但是我没有找到结果 .

Widget build(BuildContext context) {
return new Scaffold(
  drawer: _makeDrawer(),
  appBar: new AppBar(
    title: new Center(
      child: new Text("translate"),
    ),
    actions: <Widget>[
      new IconButton(icon: new Icon(Icons.people_outline), onPressed: () {})
    ],
  ),
  body: _phraseListFutureBuilder(), // this part of the code renders the listview
);

}
FutureBuilder phraseListFutureBuilder(){return new FutureBuilder(builder:(BuildContext context,AsyncSnapshot snapshot){return mPhrases.isEmpty?new CircularProgressIndicator(): buildPhrases();},future:_fetchData()); }

1 回答

  • 1

    Column 是正确的选择,但您还需要一个 Expanded 小部件来指定哪个小部件应该填充剩余空间:

    Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        TextField(
          decoration: InputDecoration(
            labelText: 'Search'
          ),
        ),
        Expanded(
          child:  _phraseListFutureBuilder(),
        )  
      ],
    );
    

相关问题