From d50ec2469fef29d2707722e0a5e1ebc44bffc380 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Mon, 20 Sep 2021 14:23:05 -0500 Subject: [PATCH] Fix overflow in stretching overscroll (#90215) --- .../lib/src/widgets/overscroll_indicator.dart | 10 ++-- .../overscroll_stretch_indicator_test.dart | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart index 2f893681c3..341a90e1e3 100644 --- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart +++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart @@ -760,10 +760,12 @@ class _StretchingOverscrollIndicatorState extends State[ + StretchingOverscrollIndicator( + axisDirection: AxisDirection.down, + child: SizedBox( + height: 300, + child: ListView.builder( + itemCount: 20, + itemBuilder: (BuildContext context, int index){ + return Padding( + padding: const EdgeInsets.all(10.0), + child: Text('Index $index'), + ); + }, + ), + ), + ), + Opacity( + opacity: 0.5, + child: Container( + color: const Color(0xD0FF0000), + height: 100, + ), + ) + ], + ) + ) + )); + + expect(find.text('Index 1'), findsOneWidget); + expect(tester.getCenter(find.text('Index 1')).dy, 51.0); + + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Index 1'))); + // Overscroll the start. + await gesture.moveBy(const Offset(0.0, 200.0)); + await tester.pumpAndSettle(); + expect(find.text('Index 1'), findsOneWidget); + expect(tester.getCenter(find.text('Index 1')).dy, greaterThan(0)); + // Image should not show the text overlapping the red area below the list. + await expectLater( + find.byType(Column), + matchesGoldenFile('overscroll_stretch.no_overflow.png'), + ); + + await gesture.up(); + await tester.pumpAndSettle(); + }); }