From a5b06f15a0b48907c818c13bdcffcab4c84f9de5 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Mon, 21 Aug 2023 20:46:23 -0500 Subject: [PATCH] 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. --- packages/flutter/lib/src/rendering/sliver_group.dart | 1 + .../flutter/test/widgets/sliver_main_axis_group_test.dart | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/packages/flutter/lib/src/rendering/sliver_group.dart b/packages/flutter/lib/src/rendering/sliver_group.dart index 8315908408..40e8ee85ec 100644 --- a/packages/flutter/lib/src/rendering/sliver_group.dart +++ b/packages/flutter/lib/src/rendering/sliver_group.dart @@ -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, ); } diff --git a/packages/flutter/test/widgets/sliver_main_axis_group_test.dart b/packages/flutter/test/widgets/sliver_main_axis_group_test.dart index 597c196acb..c0f89fa308 100644 --- a/packages/flutter/test/widgets/sliver_main_axis_group_test.dart +++ b/packages/flutter/test/widgets/sliver_main_axis_group_test.dart @@ -61,6 +61,7 @@ void main() { final RenderSliverMainAxisGroup renderGroup = tester.renderObject(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(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(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(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 {