@@ -308,4 +308,58 @@ void main() {
308
308
await gesture.up ();
309
309
await tester.pumpAndSettle ();
310
310
});
311
+
312
+ testWidgets ('Stretch does not overflow bounds of container' , (WidgetTester tester) async {
313
+ // Regression test for https://github.com/flutter/flutter/issues/90197
314
+ await tester.pumpWidget (Directionality (
315
+ textDirection: TextDirection .ltr,
316
+ child: ScrollConfiguration (
317
+ behavior: const ScrollBehavior ().copyWith (overscroll: false ),
318
+ child: Column (
319
+ children: < Widget > [
320
+ StretchingOverscrollIndicator (
321
+ axisDirection: AxisDirection .down,
322
+ child: SizedBox (
323
+ height: 300 ,
324
+ child: ListView .builder (
325
+ itemCount: 20 ,
326
+ itemBuilder: (BuildContext context, int index){
327
+ return Padding (
328
+ padding: const EdgeInsets .all (10.0 ),
329
+ child: Text ('Index $index ' ),
330
+ );
331
+ },
332
+ ),
333
+ ),
334
+ ),
335
+ Opacity (
336
+ opacity: 0.5 ,
337
+ child: Container (
338
+ color: const Color (0xD0FF0000 ),
339
+ height: 100 ,
340
+ ),
341
+ )
342
+ ],
343
+ )
344
+ )
345
+ ));
346
+
347
+ expect (find.text ('Index 1' ), findsOneWidget);
348
+ expect (tester.getCenter (find.text ('Index 1' )).dy, 51.0 );
349
+
350
+ final TestGesture gesture = await tester.startGesture (tester.getCenter (find.text ('Index 1' )));
351
+ // Overscroll the start.
352
+ await gesture.moveBy (const Offset (0.0 , 200.0 ));
353
+ await tester.pumpAndSettle ();
354
+ expect (find.text ('Index 1' ), findsOneWidget);
355
+ expect (tester.getCenter (find.text ('Index 1' )).dy, greaterThan (0 ));
356
+ // Image should not show the text overlapping the red area below the list.
357
+ await expectLater (
358
+ find.byType (Column ),
359
+ matchesGoldenFile ('overscroll_stretch.no_overflow.png' ),
360
+ );
361
+
362
+ await gesture.up ();
363
+ await tester.pumpAndSettle ();
364
+ });
311
365
}
0 commit comments