Skip to content

Commit 61e9bc0

Browse files
Piinksclocksmith
authored andcommitted
Fix overflow in stretching overscroll (flutter#90215)
1 parent b6db456 commit 61e9bc0

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

packages/flutter/lib/src/widgets/overscroll_indicator.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,12 @@ class _StretchingOverscrollIndicatorState extends State<StretchingOverscrollIndi
760760
_lastOverscrollNotification?.overscroll ?? 0.0
761761
);
762762

763-
return Transform(
764-
alignment: alignment,
765-
transform: Matrix4.diagonal3Values(x, y, 1.0),
766-
child: widget.child,
763+
return ClipRect(
764+
child: Transform(
765+
alignment: alignment,
766+
transform: Matrix4.diagonal3Values(x, y, 1.0),
767+
child: widget.child,
768+
),
767769
);
768770
},
769771
),

packages/flutter/test/widgets/overscroll_stretch_indicator_test.dart

+54
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,58 @@ void main() {
308308
await gesture.up();
309309
await tester.pumpAndSettle();
310310
});
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+
});
311365
}

0 commit comments

Comments
 (0)