File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -766,10 +766,23 @@ class _RenderSliverStickyHeaderListInner extends RenderSliverList {
766766
767767 final RenderBox ? child;
768768 switch (widget.headerPlacement._byGrowth (constraints.growthDirection)) {
769+ case _HeaderGrowthPlacement .growthStart:
770+ if (constraints.remainingPaintExtent < constraints.viewportMainAxisExtent) {
771+ // Part of the viewport is occupied already by other slivers. The way
772+ // a RenderViewport does layout means that the already-occupied part is
773+ // the part that's before this sliver in the growth direction.
774+ // Which means that's the place where the header would go.
775+ child = null ;
776+ } else {
777+ child = _findChildAtStart ();
778+ }
769779 case _HeaderGrowthPlacement .growthEnd:
780+ // The edge this sliver wants to place a header at is the one where
781+ // this sliver is free to run all the way to the viewport's edge; any
782+ // further slivers in that direction will be laid out after this one.
783+ // So if this sliver placed a child there, it's at the edge of the
784+ // whole viewport and should determine a header.
770785 child = _findChildAtEnd ();
771- case _HeaderGrowthPlacement .growthStart:
772- child = _findChildAtStart ();
773786 }
774787
775788 (parent! as _RenderSliverStickyHeaderList )._rebuildHeader (child);
Original file line number Diff line number Diff line change @@ -192,14 +192,10 @@ void main() {
192192 }));
193193 final itemWidget = itemElement.widget as _Item ;
194194 check (itemWidget.index).equals (index);
195- // TODO the `.first` calls should be unnecessary; that's another bug
196- // check(_headerIndex(tester)).equals(index);
197- check (tester.widget <_Header >(find.byType (_Header ).first).index)
198- .equals (index);
195+ check (_headerIndex (tester)).equals (index);
199196 check ((itemElement.renderObject as RenderBox ).localToGlobal (Offset (0 , 0 )))
200197 .equals (Offset (0 , item));
201- check (tester.getTopLeft (find.byType (_Header ).first))
202- .equals (Offset (0 , header));
198+ check (tester.getTopLeft (find.byType (_Header ))).equals (Offset (0 , header));
203199 }
204200
205201 check (controller.offset).equals (0 );
You can’t perform that action at this time.
0 commit comments