Sliver appbar 不拉伸颤动
Sliver appbar not stretching flutter
我很困惑为什么当我到达顶部列表时我的 sliverappbar 不拉伸和缩放。我在关注 flutter 视频
我尝试了以下代码
class AppBar5 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
title: Text("title"),
expandedHeight: 200,
stretch: true,
flexibleSpace: FlexibleSpaceBar(
background: Container(
width: MediaQuery.of(context).size.width,
height: 200,
child: Image.asset("assets/images/hot.jpg", fit: BoxFit.cover)
),
)
),
SliverList(
delegate: SliverChildBuilderDelegate(
(_, index) => ListTile(
title: Text("Index: $index"),
),
),
)
],
),
);
}
}
将 Bouncing ScrollPhysics 添加到 CustomScrollView
CustomScrollView(
physics: BouncingScrollPhysics(),
...
),
我很困惑为什么当我到达顶部列表时我的 sliverappbar 不拉伸和缩放。我在关注 flutter 视频
我尝试了以下代码
class AppBar5 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
title: Text("title"),
expandedHeight: 200,
stretch: true,
flexibleSpace: FlexibleSpaceBar(
background: Container(
width: MediaQuery.of(context).size.width,
height: 200,
child: Image.asset("assets/images/hot.jpg", fit: BoxFit.cover)
),
)
),
SliverList(
delegate: SliverChildBuilderDelegate(
(_, index) => ListTile(
title: Text("Index: $index"),
),
),
)
],
),
);
}
}
将 Bouncing ScrollPhysics 添加到 CustomScrollView
CustomScrollView(
physics: BouncingScrollPhysics(),
...
),