@@ -230,6 +230,7 @@ void main() {
230230 });
231231
232232 testWidgets ('child builder with lower and upper limits' , (WidgetTester tester) async {
233+ // Adjust the content dimensions at the end of `RenderListWheelViewport.performLayout()`
233234 final List <int > paintedChildren = < int > [];
234235
235236 final FixedExtentScrollController controller =
@@ -285,6 +286,69 @@ void main() {
285286 });
286287
287288 group ('layout' , () {
289+ // Regression test for https://github.com/flutter/flutter/issues/90953
290+ testWidgets ('ListWheelScrollView childDelegate update test 2' , (WidgetTester tester) async {
291+ final FixedExtentScrollController controller = FixedExtentScrollController ( initialItem: 2 );
292+ Widget buildFrame (int childCount) {
293+ return Directionality (
294+ textDirection: TextDirection .ltr,
295+ child: ListWheelScrollView .useDelegate (
296+ controller: controller,
297+ itemExtent: 400.0 ,
298+ onSelectedItemChanged: (_) { },
299+ childDelegate: ListWheelChildBuilderDelegate (
300+ childCount: childCount,
301+ builder: (BuildContext context, int index) {
302+ return SizedBox (
303+ width: 400.0 ,
304+ height: 400.0 ,
305+ child: Text (index.toString ()),
306+ );
307+ },
308+ ),
309+ ),
310+ );
311+ }
312+
313+ await tester.pumpWidget (buildFrame (5 ));
314+ expect (find.text ('0' ), findsNothing);
315+ expect (tester.renderObject (find.text ('1' )).attached, true );
316+ expect (tester.renderObject (find.text ('2' )).attached, true );
317+ expect (tester.renderObject (find.text ('3' )).attached, true );
318+ expect (find.text ('4' ), findsNothing);
319+
320+ // Remove the last 3 items.
321+ await tester.pumpWidget (buildFrame (2 ));
322+ expect (tester.renderObject (find.text ('0' )).attached, true );
323+ expect (tester.renderObject (find.text ('1' )).attached, true );
324+ expect (find.text ('3' ), findsNothing);
325+
326+ // Add 3 items at the end.
327+ await tester.pumpWidget (buildFrame (5 ));
328+ expect (tester.renderObject (find.text ('0' )).attached, true );
329+ expect (tester.renderObject (find.text ('1' )).attached, true );
330+ expect (tester.renderObject (find.text ('2' )).attached, true );
331+ expect (find.text ('3' ), findsNothing);
332+ expect (find.text ('4' ), findsNothing);
333+
334+
335+ // Scroll to the last item.
336+ final TestGesture scrollGesture = await tester.startGesture (const Offset (10.0 , 10.0 ));
337+ await scrollGesture.moveBy (const Offset (0.0 , - 1200.0 ));
338+ await tester.pump ();
339+ expect (find.text ('0' ), findsNothing);
340+ expect (find.text ('1' ), findsNothing);
341+ expect (find.text ('2' ), findsNothing);
342+ expect (tester.renderObject (find.text ('3' )).attached, true );
343+ expect (tester.renderObject (find.text ('4' )).attached, true );
344+
345+ // Remove the last 3 items.
346+ await tester.pumpWidget (buildFrame (2 ));
347+ expect (tester.renderObject (find.text ('0' )).attached, true );
348+ expect (tester.renderObject (find.text ('1' )).attached, true );
349+ expect (find.text ('3' ), findsNothing);
350+ });
351+
288352 // Regression test for https://github.com/flutter/flutter/issues/58144
289353 testWidgets ('ListWheelScrollView childDelegate update test' , (WidgetTester tester) async {
290354 final FixedExtentScrollController controller = FixedExtentScrollController ();
0 commit comments