Skip to content

Commit 3de58fe

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 7b03839 commit 3de58fe

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
@@ -556,6 +556,19 @@ class _RenderSliverStickyHeaderList extends RenderSliver with RenderSliverHelper
556556
child!.layout(constraints, parentUsesSize: true);
557557
SliverGeometry geometry = child!.geometry!;
558558

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

0 commit comments

Comments
 (0)