[英]SliverAppBar is not working even after adding expanded widget
在 flutter 中制作可折叠 header 的正确方法是什么?
我尝试了以下但没有奏效。 我做错了什么,我该如何解决?
return CustomScrollView(
shrinkWrap: true,
slivers: [
SliverAppBar(
expandedHeight: 200,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
title: Text(title),
background: Image(image: AssetImage(imgPath), fit: BoxFit.cover),
),
),
SliverFillRemaining(
child: Column(
children: [Text('some cool text here')],
),
)
],
);
是的,这是一种正确的方法,而且效果很好。 如果您问为什么它没有完全崩溃,您应该检查“固定”值。 如果将其设置为“false”,它将完全崩溃。
SliverAppBar(
expandedHeight: 200,
pinned: false,
flexibleSpace: FlexibleSpaceBar(
title: Text(title),
background: Image(image: AssetImage(imgPath), fit: BoxFit.cover),
),
),
您可以查看此文档以获取有关 SliverAppBar 的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.