[英]How to create custom slivers in flutter?
I want to create a custom container under the sliver appbar like the right screen in the image我想在 sliver appbar 下创建一个自定义容器,就像图像中的右侧屏幕一样
https://cdn.dribbble.com/users/1720296/screenshots/6918712/dribbble_blog_2x.jpg https://cdn.dribbble.com/users/1720296/screenshots/6918712/dribbble_blog_2x.jpg
You can use custom header with SliverPersistentHeaderDelegate
,您可以将自定义 header 与SliverPersistentHeaderDelegate
一起使用,
This is your custom SliverPersistentHeaderDelegate
这是您的自定义SliverPersistentHeaderDelegate
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
@override
double get minExtent => 100;
@override
double get maxExtent => 300;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
...
);
}
@override
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
return false;
}
}
And use it like this并像这样使用它
SliverPersistentHeader(
delegate: _SliverAppBarDelegate(
...
),
pinned: true,
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.