如何将SearchView放在ListView之上?

时间:2018-06-29 19:03:34

标签: flutter

我是新手,正在尝试将searchView堆叠在ListView之上。我看起来像这样:

enter image description here

我不知道如何在颤动下实现这种布局,我尝试使用列(使应用程序崩溃),使用堆栈(与小部件重叠),最后尝试在第一个中添加搜索小部件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(){     返回新的FutureBuilder(         构建器:(BuildContext上下文,AsyncSnapshot快照){           返回mPhrases.isEmpty               ?新的CircularProgressIndicator()               :_buildPhrases();         },         未来:_fetchData());   }

1 个答案:

答案 0 :(得分:1)

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

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