Skip to content

Commit 366144d

Browse files
committed
sticky_header [nfc]: Add asserts from studying possible child geometry; note a bug
The logic below -- particularly in the allowOverflow true case, where it constructs a new SliverGeometry from scratch -- has been implicitly relying on several of these facts already. These wouldn't be true of an arbitrary sliver child; but this sliver knows what type of child it actually has, and they are true of that one. So write down the specific assumptions we can take from that. Reading through [RenderSliverList.performLayout] to see what it can produce as the child geometry also made clear there's another case that this method isn't currently correctly handling at all: the case where scrollOffsetCorrection is non-null. Filed an issue for that; add a todo-comment for it.
1 parent ff252d7 commit 366144d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/widgets/sticky_header.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,19 @@ class _RenderSliverStickyHeaderList extends RenderSliver with RenderSliverHelper
564564
child!.layout(constraints, parentUsesSize: true);
565565
SliverGeometry geometry = child!.geometry!;
566566

567+
// TODO(#1309) handle the scrollOffsetCorrection case, passing it through
568+
569+
// We assume [child]'s geometry is free of certain complications.
570+
// Probably most or all of these *could* be handled if necessary, just at
571+
// the cost of further complicating this code. Fortunately they aren't,
572+
// because [RenderSliverList.performLayout] never has these complications.
573+
assert(geometry.paintOrigin == 0);
574+
assert(geometry.layoutExtent == geometry.paintExtent);
575+
assert(geometry.hitTestExtent == geometry.paintExtent);
576+
assert(geometry.visible == (geometry.paintExtent > 0));
577+
assert(geometry.maxScrollObstructionExtent == 0);
578+
assert(geometry.crossAxisExtent == null);
579+
567580
if (header != null) {
568581
header!.layout(constraints.asBoxConstraints(), parentUsesSize: true);
569582
final headerExtent = header!.size.onAxis(constraints.axis);

0 commit comments

Comments
 (0)