Fix sliver offset calculation again (#18738)
This should fix https://github.com/flutter/flutter/issues/18731 and I've added a unit test for it.
This commit is contained in:
parent
7213a7805a
commit
e62626fd56
@ -525,10 +525,9 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver
|
|||||||
if (addExtent)
|
if (addExtent)
|
||||||
childOffset += mainAxisUnit * paintExtentOf(child);
|
childOffset += mainAxisUnit * paintExtentOf(child);
|
||||||
|
|
||||||
// If the child's visible interval (mainAxisLowerBound, mainAxisLowerBound + paintExtentOf(child))
|
// If the child's visible interval (mainAxisDelta, mainAxisDelta + paintExtentOf(child))
|
||||||
// does not intersect the paint extent interval (0, constraints.remainingPaintExtent), it's hidden.
|
// does not intersect the paint extent interval (0, constraints.remainingPaintExtent), it's hidden.
|
||||||
final double mainAxisLowerBound = mainAxisDelta + (addExtent ? paintExtentOf(child) : 0);
|
if (mainAxisDelta < constraints.remainingPaintExtent && mainAxisDelta + paintExtentOf(child) > 0)
|
||||||
if (mainAxisLowerBound < constraints.remainingPaintExtent && mainAxisLowerBound + paintExtentOf(child) > 0)
|
|
||||||
context.paintChild(child, childOffset);
|
context.paintChild(child, childOffset);
|
||||||
|
|
||||||
child = childAfter(child);
|
child = childAfter(child);
|
||||||
|
@ -491,4 +491,30 @@ void main() {
|
|||||||
final RenderObject renderObject = tester.renderObject(find.byType(Scrollable));
|
final RenderObject renderObject = tester.renderObject(find.byType(Scrollable));
|
||||||
expect(renderObject, paintsExactlyCountTimes(#drawParagraph, 10));
|
expect(renderObject, paintsExactlyCountTimes(#drawParagraph, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('ListView should paint with rtl', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
new Directionality(
|
||||||
|
textDirection: TextDirection.rtl,
|
||||||
|
child: new Container(
|
||||||
|
height: 200.0,
|
||||||
|
child: new ListView.builder(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 0.0, vertical: 0.0),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemExtent: 200.0,
|
||||||
|
itemCount: 10,
|
||||||
|
itemBuilder: (_, int i) => new Container(
|
||||||
|
height: 200.0,
|
||||||
|
width: 200.0,
|
||||||
|
color: i % 2 == 0 ? Colors.black : Colors.red,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final RenderObject renderObject = tester.renderObject(find.byType(Scrollable));
|
||||||
|
expect(renderObject, paintsExactlyCountTimes(#drawRect, 4));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user