Skip to content

Commit ff252d7

Browse files
committed
sticky_header: Use cacheExtent from child
This is the right thing, as the comment explains. Conveniently it's also simpler.
1 parent 40ac6de commit ff252d7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/widgets/sticky_header.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,21 @@ class _RenderSliverStickyHeaderList extends RenderSliver with RenderSliverHelper
576576
// and even if the whole child sliver is smaller than the header.
577577

578578
final paintedHeaderSize = calculatePaintOffset(constraints, from: 0, to: headerExtent);
579-
final cacheExtent = calculateCacheOffset(constraints, from: 0, to: headerExtent);
580-
581579
geometry = SliverGeometry( // TODO review interaction with other slivers
582580
scrollExtent: geometry.scrollExtent,
583581
layoutExtent: geometry.layoutExtent,
584582
paintExtent: math.max(geometry.paintExtent, paintedHeaderSize),
585-
cacheExtent: math.max(geometry.cacheExtent, cacheExtent),
586583
maxPaintExtent: math.max(geometry.maxPaintExtent, headerExtent),
587584
hitTestExtent: math.max(geometry.hitTestExtent, paintedHeaderSize),
588585
hasVisualOverflow: geometry.hasVisualOverflow
589586
|| headerExtent > constraints.remainingPaintExtent,
587+
588+
// The cache extent is an extension of layout, not paint; it controls
589+
// where the next sliver should start laying out content. (See
590+
// [SliverConstraints.remainingCacheExtent].) The header isn't meant
591+
// to affect where the next sliver gets laid out, so it shouldn't
592+
// affect the cache extent.
593+
cacheExtent: geometry.cacheExtent,
590594
);
591595

592596
headerOffset = _headerAtCoordinateEnd()

0 commit comments

Comments
 (0)