Skip to content

Commit

Permalink
Fix clipBehavior ignored in Scrollable of SingleChildScrollView (#133…
Browse files Browse the repository at this point in the history
…696)

Fixes flutter/flutter#133330

The clipBehavior was not passed to the underlying Scrollable, which informs things like the clip on the StretchingOverscrollIndicator.
  • Loading branch information
Piinks authored Aug 31, 2023
1 parent 956999a commit cf051e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class SingleChildScrollView extends StatelessWidget {
controller: scrollController,
physics: physics,
restorationId: restorationId,
clipBehavior: clipBehavior,
viewportBuilder: (BuildContext context, ViewportOffset offset) {
return _SingleChildViewport(
axisDirection: axisDirection,
Expand Down
20 changes: 18 additions & 2 deletions packages/flutter/test/widgets/single_child_scroll_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,29 @@ void main() {
renderObject.paint(context, Offset.zero); // ignore: avoid_dynamic_calls
expect(context.clipBehavior, equals(Clip.hardEdge));

// 3rd, pump a new widget to check that the render object can update its clip behavior.
// 3rd, check that the underlying Scrollable has the same clipBehavior
// Regression test for https://github.com/flutter/flutter/issues/133330
Finder scrollable = find.byWidgetPredicate((Widget widget) => widget is Scrollable);
expect(
(tester.widget(scrollable) as Scrollable).clipBehavior,
Clip.hardEdge,
);

// 4th, pump a new widget to check that the render object can update its clip behavior.
await tester.pumpWidget(SingleChildScrollView(clipBehavior: Clip.antiAlias, child: Container(height: 2000.0)));
expect(renderObject.clipBehavior, equals(Clip.antiAlias)); // ignore: avoid_dynamic_calls

// 4th, check that a non-default clip behavior can be sent to the painting context.
// 5th, check that a non-default clip behavior can be sent to the painting context.
renderObject.paint(context, Offset.zero); // ignore: avoid_dynamic_calls
expect(context.clipBehavior, equals(Clip.antiAlias));

// 6th, check that the underlying Scrollable has the same clipBehavior
// Regression test for https://github.com/flutter/flutter/issues/133330
scrollable = find.byWidgetPredicate((Widget widget) => widget is Scrollable);
expect(
(tester.widget(scrollable) as Scrollable).clipBehavior,
Clip.antiAlias,
);
});

testWidgets('SingleChildScrollView control test', (WidgetTester tester) async {
Expand Down

0 comments on commit cf051e7

Please sign in to comment.