Unverified Commit e62626fd authored by liyuqian's avatar liyuqian Committed by GitHub

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.
parent 7213a780
......@@ -525,10 +525,9 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver
if (addExtent)
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.
final double mainAxisLowerBound = mainAxisDelta + (addExtent ? paintExtentOf(child) : 0);
if (mainAxisLowerBound < constraints.remainingPaintExtent && mainAxisLowerBound + paintExtentOf(child) > 0)
if (mainAxisDelta < constraints.remainingPaintExtent && mainAxisDelta + paintExtentOf(child) > 0)
context.paintChild(child, childOffset);
child = childAfter(child);
......
......@@ -491,4 +491,30 @@ void main() {
final RenderObject renderObject = tester.renderObject(find.byType(Scrollable));
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));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment