下面是带有折叠子项和展开子项的 sliver 持久标头的代码。当滚动折叠的孩子不点击,而只是显示。是堆栈的问题,有没有办法解决它。我相信它来自 Stack,但我不知道如何绕过它。该类用于长条子持久标头,并且子项是折叠的子项和子项
class _SliverAppbarDelegate extends SliverPersistentHeaderDelegate {
final double minHeight;
final double maxHeight;
final Widget child;
// final Widget collapsedchild;
bool shrink;
ScrollPosition _position;
_SliverAppbarDelegate({
@required this.minHeight,
// @required this.collapsedchild,
@required this.maxHeight,
@required this.child,
});
@override
double get minExtent => minHeight;
@override
double get maxExtent => maxHeight;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Stack(children: [
Opacity(opacity: disappear(shrinkOffset), child: child),buildAppbar(shrinkOffset),
],
);
}
// ignore: slash_for_doc_comments
@override
bool shouldRebuild(_SliverAppbarDelegate oldDelegate) {
return
maxHeight != oldDelegate.maxHeight ||
minHeight != oldDelegate.minHeight ||
child != oldDelegate.child ;
// collapsedchild != oldDelegate.collapsedchild;
}
double appear(double shrinkOffset) => shrinkOffset / maxHeight;
double disappear(double shrinkOffset) => 1 - shrinkOffset / maxHeight;
Widget buildAppbar(double shrinkOffset) =>
Opacity(opacity: appear(shrinkOffset), child: CalendarCarousel(weekFormat: true,));
}