Unverified Commit d50ec246 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Fix overflow in stretching overscroll (#90215)

parent 8d5d37d6
......@@ -760,10 +760,12 @@ class _StretchingOverscrollIndicatorState extends State<StretchingOverscrollIndi
_lastOverscrollNotification?.overscroll ?? 0.0
);
return Transform(
alignment: alignment,
transform: Matrix4.diagonal3Values(x, y, 1.0),
child: widget.child,
return ClipRect(
child: Transform(
alignment: alignment,
transform: Matrix4.diagonal3Values(x, y, 1.0),
child: widget.child,
),
);
},
),
......
......@@ -308,4 +308,58 @@ void main() {
await gesture.up();
await tester.pumpAndSettle();
});
testWidgets('Stretch does not overflow bounds of container', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/90197
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: ScrollConfiguration(
behavior: const ScrollBehavior().copyWith(overscroll: false),
child: Column(
children: <Widget>[
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();
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment