Unverified Commit 38dae1bf authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Update stretching overscroll clip behavior (#97678)

parent 0eedf420
...@@ -785,10 +785,11 @@ class _StretchingOverscrollIndicatorState extends State<StretchingOverscrollIndi ...@@ -785,10 +785,11 @@ class _StretchingOverscrollIndicatorState extends State<StretchingOverscrollIndi
// Only clip if the viewport dimension is smaller than that of the // Only clip if the viewport dimension is smaller than that of the
// screen size in the main axis. If the viewport takes up the whole // screen size in the main axis. If the viewport takes up the whole
// screen, overflow from transforming the viewport is irrelevant. // screen, overflow from transforming the viewport is irrelevant.
if (stretch != 0.0 && viewportDimension != mainAxisSize) { return ClipRect(
return ClipRect(child: transform); clipBehavior: stretch != 0.0 && viewportDimension != mainAxisSize
} ? Clip.hardEdge : Clip.none,
return transform; child: transform,
);
}, },
), ),
); );
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// machines. // machines.
@Tags(<String>['reduced-test-set']) @Tags(<String>['reduced-test-set'])
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -392,4 +393,62 @@ void main() { ...@@ -392,4 +393,62 @@ void main() {
await gesture.up(); await gesture.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgets('Clip behavior is updated as needed', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/97867
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: MediaQuery(
data: const MediaQueryData(size: Size(800.0, 600.0)),
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);
RenderClipRect renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first;
// Currently not clipping
expect(renderClip.clipBehavior, equals(Clip.none));
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));
renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first;
// Now clipping
expect(renderClip.clipBehavior, equals(Clip.hardEdge));
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