[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix visual overflow for SliverMainAxisGroup (flutter#132989)
Browse files Browse the repository at this point in the history
Fixes flutter#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.
  • Loading branch information
Piinks committed Aug 22, 2023
1 parent efbf63d commit 22bafdd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/flutter/lib/src/rendering/sliver_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,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,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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 {
Expand Down Expand Up @@ -109,6 +110,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 {
Expand Down Expand Up @@ -165,6 +167,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 {
Expand Down Expand Up @@ -222,6 +225,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 {
Expand Down

0 comments on commit 22bafdd

Please sign in to comment.