Fix visual overflow for SliverMainAxisGroup (#132989)

Fixes https://github.com/flutter/flutter/issues/132788

The SliverGeometry was not set properly for SliverMainAxisGroup. Omitting hasVisualOverflow affected the Viewport's choice to apply a clip, leading to the sliver being rendered outside of the bounds of the viewport.
This commit is contained in:
Kate Lovett 2023-08-21 20:46:23 -05:00 committed by GitHub
parent 1cf3925d4d
commit a5b06f15a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -288,6 +288,7 @@ class RenderSliverMainAxisGroup extends RenderSliver with ContainerRenderObjectM
scrollExtent: totalScrollExtent,
paintExtent: calculatePaintOffset(constraints, from: 0, to: totalScrollExtent),
maxPaintExtent: maxPaintExtent,
hasVisualOverflow: totalScrollExtent > constraints.remainingPaintExtent || constraints.scrollOffset > 0.0,
);
}

View File

@ -61,6 +61,7 @@ void main() {
final RenderSliverMainAxisGroup renderGroup =
tester.renderObject<RenderSliverMainAxisGroup>(find.byType(SliverMainAxisGroup));
expect(renderGroup.geometry!.scrollExtent, equals(300 * 20 + 200 * 20));
expect(renderGroup.geometry!.hasVisualOverflow, isTrue);
});
testWidgets('SliverMainAxisGroup is laid out properly when reversed', (WidgetTester tester) async {
@ -112,6 +113,7 @@ void main() {
final RenderSliverMainAxisGroup renderGroup =
tester.renderObject<RenderSliverMainAxisGroup>(find.byType(SliverMainAxisGroup));
expect(renderGroup.geometry!.scrollExtent, equals(300 * 20 + 200 * 20));
expect(renderGroup.geometry!.hasVisualOverflow, isTrue);
});
testWidgets('SliverMainAxisGroup is laid out properly when horizontal', (WidgetTester tester) async {
@ -168,6 +170,7 @@ void main() {
final RenderSliverMainAxisGroup renderGroup =
tester.renderObject<RenderSliverMainAxisGroup>(find.byType(SliverMainAxisGroup));
expect(renderGroup.geometry!.scrollExtent, equals(300 * 20 + 200 * 20));
expect(renderGroup.geometry!.hasVisualOverflow, isTrue);
});
testWidgets('SliverMainAxisGroup is laid out properly when horizontal, reversed', (WidgetTester tester) async {
@ -225,6 +228,7 @@ void main() {
final RenderSliverMainAxisGroup renderGroup =
tester.renderObject<RenderSliverMainAxisGroup>(find.byType(SliverMainAxisGroup));
expect(renderGroup.geometry!.scrollExtent, equals(300 * 20 + 200 * 20));
expect(renderGroup.geometry!.hasVisualOverflow, isTrue);
});
testWidgets('Hit test works properly on various parts of SliverMainAxisGroup', (WidgetTester tester) async {