SliverAppBar 包含文本字段搜索框,但滚动时会向上滚动。如何在滚动时显示搜索框。我做了我自己的工作,但没有工作。如果有任何关于 Sliverappbar 和 Slivergrid 的资源,它也很有用。但是现在如何固定 appbar 文本字段?
SliverAppBar(
//snap: true,
stretch: true,
//floating: true,
title: Text('Home'),
centerTitle: true,
expandedHeight: 100.0,
backgroundColor: Colors.red,
leading: IconButton(
icon: Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {},
),
actions: [
IconButton(
icon: Icon(
Icons.notifications,
color: Colors.white,
),
onPressed: () {},
),
],
//floating: false,
pinned: true,
flexibleSpace: ListView(
children: [
SizedBox(
height: 40.0,
),
Padding(
padding: const EdgeInsets.only(
top: 12.0,
bottom: 12.0,
left: 8.0,
right: 8.0,
),
child: Container(
height: 40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5.0)),
child: TextField(
decoration: InputDecoration(
labelText: "Search products...",
border: InputBorder.none,
icon: IconButton(onPressed: () {}, icon: Icon(Icons.search)),
),
),
),
),
],
),
);