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 @@ -774,10 +774,23 @@ class _RenderSliverStickyHeaderListInner extends RenderSliverList {
774774
775775 final RenderBox ? child;
776776 switch (widget.headerPlacement._byGrowth (constraints.growthDirection)) {
777+ case _HeaderGrowthPlacement .growthStart:
778+ if (constraints.remainingPaintExtent < constraints.viewportMainAxisExtent) {
779+ // Part of the viewport is occupied already by other slivers. The way
780+ // a RenderViewport does layout means that the already-occupied part is
781+ // the part that's before this sliver in the growth direction.
782+ // Which means that's the place where the header would go.
783+ child = null ;
784+ } else {
785+ child = _findChildAtStart ();
786+ }
777787 case _HeaderGrowthPlacement .growthEnd:
788+ // The edge this sliver wants to place a header at is the one where
789+ // this sliver is free to run all the way to the viewport's edge; any
790+ // further slivers in that direction will be laid out after this one.
791+ // So if this sliver placed a child there, it's at the edge of the
792+ // whole viewport and should determine a header.
778793 child = _findChildAtEnd ();
779- case _HeaderGrowthPlacement .growthStart:
780- child = _findChildAtStart ();
781794 }
782795
783796 (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