Skip to content

Commit 995b332

Browse files
authored
Revert "Make RenderSliverGrid more accurately report overflow" (#106123)
1 parent ede7fc6 commit 995b332

File tree

2 files changed

+5
-54
lines changed

2 files changed

+5
-54
lines changed

packages/flutter/lib/src/rendering/sliver_grid.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor {
658658
leadingScrollOffset: leadingScrollOffset,
659659
trailingScrollOffset: trailingScrollOffset,
660660
);
661+
661662
final double paintExtent = calculatePaintOffset(
662663
constraints,
663664
from: math.min(constraints.scrollOffset, leadingScrollOffset),
@@ -674,7 +675,8 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor {
674675
paintExtent: paintExtent,
675676
maxPaintExtent: estimatedTotalExtent,
676677
cacheExtent: cacheExtent,
677-
hasVisualOverflow: estimatedTotalExtent > paintExtent || constraints.scrollOffset > 0.0 || constraints.overlap != 0.0,
678+
// Conservative to avoid complexity.
679+
hasVisualOverflow: true,
678680
);
679681

680682
// We may have started the layout while scrolled to the end, which

packages/flutter/test/widgets/grid_view_test.dart

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -645,50 +645,13 @@ void main() {
645645
expect(counters[4], 2);
646646
});
647647

648-
testWidgets('GridView does not report visual overflow unnecessarily', (WidgetTester tester) async {
649-
await tester.pumpWidget(
650-
Directionality(
651-
textDirection: TextDirection.ltr,
652-
child: GridView(
653-
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
654-
children: <Widget>[
655-
Container(height: 200.0),
656-
],
657-
),
658-
),
659-
);
660-
661-
// 1st, check that the render object has received the default clip behavior.
662-
final RenderViewport renderObject = tester.allRenderObjects.whereType<RenderViewport>().first;
663-
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
664-
665-
// The context will get Clip.none because there is no actual visual overflow.
666-
final TestClipPaintingContext context = TestClipPaintingContext();
667-
renderObject.paint(context, Offset.zero);
668-
expect(context.clipBehavior, equals(Clip.none));
669-
});
670-
671648
testWidgets('GridView respects clipBehavior', (WidgetTester tester) async {
672649
await tester.pumpWidget(
673650
Directionality(
674651
textDirection: TextDirection.ltr,
675652
child: GridView(
676653
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
677-
children: <Widget>[
678-
Container(height: 2000.0),
679-
Container(height: 2000.0),
680-
Container(height: 2000.0),
681-
Container(height: 2000.0),
682-
Container(height: 2000.0),
683-
Container(height: 2000.0),
684-
Container(height: 2000.0),
685-
Container(height: 2000.0),
686-
Container(height: 2000.0),
687-
Container(height: 2000.0),
688-
Container(height: 2000.0),
689-
Container(height: 2000.0),
690-
Container(height: 2000.0),
691-
],
654+
children: <Widget>[Container(height: 2000.0)],
692655
),
693656
),
694657
);
@@ -709,21 +672,7 @@ void main() {
709672
child: GridView(
710673
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
711674
clipBehavior: Clip.antiAlias,
712-
children: <Widget>[
713-
Container(height: 2000.0),
714-
Container(height: 2000.0),
715-
Container(height: 2000.0),
716-
Container(height: 2000.0),
717-
Container(height: 2000.0),
718-
Container(height: 2000.0),
719-
Container(height: 2000.0),
720-
Container(height: 2000.0),
721-
Container(height: 2000.0),
722-
Container(height: 2000.0),
723-
Container(height: 2000.0),
724-
Container(height: 2000.0),
725-
Container(height: 2000.0),
726-
],
675+
children: <Widget>[Container(height: 2000.0)],
727676
),
728677
),
729678
);

0 commit comments

Comments
 (0)