@@ -288,6 +288,44 @@ void main() {
288288 });
289289
290290 group ('layout' , () {
291+ testWidgets ('Flings with high velocity should not break the children lower and upper limits' , (WidgetTester tester) async {
292+ // Regression test for https://github.com/flutter/flutter/issues/112526
293+ final FixedExtentScrollController controller = FixedExtentScrollController ();
294+ Widget buildFrame () {
295+ return Directionality (
296+ textDirection: TextDirection .ltr,
297+ child: ListWheelScrollView .useDelegate (
298+ physics: const FixedExtentScrollPhysics (),
299+ controller: controller,
300+ itemExtent: 400.0 ,
301+ onSelectedItemChanged: (_) { },
302+ childDelegate: ListWheelChildBuilderDelegate (
303+ builder: (BuildContext context, int index) {
304+ if (index < 0 || index > 5 ) {
305+ return null ;
306+ }
307+ return SizedBox (
308+ width: 400.0 ,
309+ height: 400.0 ,
310+ child: Text (index.toString ()),
311+ );
312+ },
313+ ),
314+ ),
315+ );
316+ }
317+
318+ await tester.pumpWidget (buildFrame ());
319+ expect (tester.renderObject (find.text ('0' )).attached, true );
320+ expect (tester.renderObject (find.text ('1' )).attached, true );
321+ expect (find.text ('2' ), findsNothing);
322+ expect (controller.selectedItem, 0 );
323+
324+ // Flings with high velocity and stop at the child boundary.
325+ await tester.fling (find.byType (ListWheelScrollView ), const Offset (0.0 , 40000.0 ), 8000.0 );
326+ expect (controller.selectedItem, 0 );
327+ }, variant: TargetPlatformVariant (TargetPlatform .values.toSet ()));
328+
291329 // Regression test for https://github.com/flutter/flutter/issues/90953
292330 testWidgets ('ListWheelScrollView childDelegate update test 2' , (WidgetTester tester) async {
293331 final FixedExtentScrollController controller = FixedExtentScrollController ( initialItem: 2 );
0 commit comments