我是Flutter的新手。我想在SliverAppBar中显示搜索框,并在底部的网格视图中显示项目。这样,当用户向上滑动时,它只会在Sliver应用程序内显示搜索框。现在看起来像这样https://ibb.co/MB4Ww6v。我想使搜索框位于sliver应用程序的底部,如图中的红色所示。
这是我的代码。
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
pinned: true,
expandedHeight: 200,
centerTitle: true,
flexibleSpace: AppBar(
title: Container(
height: 45,
child: TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 5, left: 15),
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {
print('sesarch');
},
),
filled: true,
fillColor: Colors.white,
hintText: "What are you looking for ?",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
),
),
),
),
elevation: 20,
),
),
SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
height: 100,
child: Center(
child: Text('eee'),
),
);
},
),
),
],
),
);
}