@@ -645,13 +645,50 @@ 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+
648671 testWidgets ('GridView respects clipBehavior' , (WidgetTester tester) async {
649672 await tester.pumpWidget (
650673 Directionality (
651674 textDirection: TextDirection .ltr,
652675 child: GridView (
653676 gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount (crossAxisCount: 3 ),
654- children: < Widget > [Container (height: 2000.0 )],
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+ ],
655692 ),
656693 ),
657694 );
@@ -672,7 +709,21 @@ void main() {
672709 child: GridView (
673710 gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount (crossAxisCount: 3 ),
674711 clipBehavior: Clip .antiAlias,
675- children: < Widget > [Container (height: 2000.0 )],
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+ ],
676727 ),
677728 ),
678729 );
0 commit comments