File tree 2 files changed +17
-8
lines changed
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 {
766
766
767
767
final RenderBox ? child;
768
768
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
+ }
769
779
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.
770
785
child = _findChildAtEnd ();
771
- case _HeaderGrowthPlacement .growthStart:
772
- child = _findChildAtStart ();
773
786
}
774
787
775
788
(parent! as _RenderSliverStickyHeaderList )._rebuildHeader (child);
Original file line number Diff line number Diff line change @@ -192,14 +192,10 @@ void main() {
192
192
}));
193
193
final itemWidget = itemElement.widget as _Item ;
194
194
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);
199
196
check ((itemElement.renderObject as RenderBox ).localToGlobal (Offset (0 , 0 )))
200
197
.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));
203
199
}
204
200
205
201
check (controller.offset).equals (0 );
You can’t perform that action at this time.
0 commit comments