Unverified Commit 3ba249a6 authored by Viren Khatri's avatar Viren Khatri Committed by GitHub

relayout active ListWheelScrollView children every performLayout (#124476)

during performLayout, active children's constraints were updated, but they weren't laid out again w.r.t their parent (ListWheelScrollView).

Fixes #123497
parent 40755034
......@@ -763,8 +763,9 @@ class RenderListWheelViewport
// Relayout all active children.
RenderBox? child = firstChild;
int index = currentFirstIndex;
while (child != null) {
child.layout(childConstraints, parentUsesSize: true);
_layoutChild(child, childConstraints, index++);
child = childAfter(child);
}
......
......@@ -604,6 +604,41 @@ void main() {
// centered.
expect(viewport.childCount, 13);
});
testWidgets('Active children are laid out with correct offset', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/123497
Future<void> buildWidget(double width) async {
return tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: ListWheelScrollView(
itemExtent: 100.0,
children: <Widget>[
SizedBox(
width: width,
child: const Center(child: Text('blah')),
),
],
),
),
);
}
double getSizedBoxWidth() => tester.getSize(find.byType(SizedBox)).width;
double getSizedBoxCenterX() => tester.getCenter(find.byType(SizedBox)).dx;
await buildWidget(200.0);
expect(getSizedBoxWidth(), 200.0);
expect(getSizedBoxCenterX(), 400.0);
await buildWidget(100.0);
expect(getSizedBoxWidth(), 100.0);
expect(getSizedBoxCenterX(), 400.0);
await buildWidget(300.0);
expect(getSizedBoxWidth(), 300.0);
expect(getSizedBoxCenterX(), 400.0);
});
});
group('pre-transform viewport', () {
......
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