@@ -617,26 +617,38 @@ class _RenderSliverStickyHeaderList extends RenderSliver with RenderSliverHelper
617
617
// even if the (visible part of the) item is smaller than the header,
618
618
// and even if the whole child sliver is smaller than the header.
619
619
620
- final paintedHeaderSize = calculatePaintOffset (constraints, from: 0 , to: headerExtent);
621
- geometry = SliverGeometry ( // TODO review interaction with other slivers
622
- scrollExtent: geometry.scrollExtent,
623
- layoutExtent: childExtent,
624
- paintExtent: math.max (childExtent, paintedHeaderSize),
625
- maxPaintExtent: math.max (geometry.maxPaintExtent, headerExtent),
626
- hasVisualOverflow: geometry.hasVisualOverflow
627
- || headerExtent > constraints.remainingPaintExtent,
628
-
629
- // The cache extent is an extension of layout, not paint; it controls
630
- // where the next sliver should start laying out content. (See
631
- // [SliverConstraints.remainingCacheExtent].) The header isn't meant
632
- // to affect where the next sliver gets laid out, so it shouldn't
633
- // affect the cache extent.
634
- cacheExtent: geometry.cacheExtent,
635
- );
620
+ if (headerExtent <= childExtent) {
621
+ // The header fits within the child sliver.
622
+ // So it doesn't affect this sliver's overall geometry.
636
623
637
- headerOffset = _headerAtCoordinateEnd ()
638
- ? childExtent - headerExtent
639
- : 0.0 ;
624
+ headerOffset = _headerAtCoordinateEnd ()
625
+ ? childExtent - headerExtent
626
+ : 0.0 ;
627
+ } else {
628
+ // The header will overflow the child sliver.
629
+ // That makes this sliver's geometry a bit more complicated.
630
+
631
+ final paintedHeaderSize = calculatePaintOffset (constraints, from: 0 , to: headerExtent);
632
+ geometry = SliverGeometry ( // TODO review interaction with other slivers
633
+ scrollExtent: geometry.scrollExtent,
634
+ layoutExtent: childExtent,
635
+ paintExtent: math.max (childExtent, paintedHeaderSize),
636
+ maxPaintExtent: math.max (geometry.maxPaintExtent, headerExtent),
637
+ hasVisualOverflow: geometry.hasVisualOverflow
638
+ || headerExtent > constraints.remainingPaintExtent,
639
+
640
+ // The cache extent is an extension of layout, not paint; it controls
641
+ // where the next sliver should start laying out content. (See
642
+ // [SliverConstraints.remainingCacheExtent].) The header isn't meant
643
+ // to affect where the next sliver gets laid out, so it shouldn't
644
+ // affect the cache extent.
645
+ cacheExtent: geometry.cacheExtent,
646
+ );
647
+
648
+ headerOffset = _headerAtCoordinateEnd ()
649
+ ? childExtent - headerExtent
650
+ : 0.0 ;
651
+ }
640
652
} else {
641
653
// The header's item has [StickyHeaderItem.allowOverflow] false.
642
654
// Keep the header within the item, pushing the header partly out of
0 commit comments