@@ -645,13 +645,50 @@ void main() {
645
645
expect (counters[4 ], 2 );
646
646
});
647
647
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
+
648
671
testWidgets ('GridView respects clipBehavior' , (WidgetTester tester) async {
649
672
await tester.pumpWidget (
650
673
Directionality (
651
674
textDirection: TextDirection .ltr,
652
675
child: GridView (
653
676
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
+ ],
655
692
),
656
693
),
657
694
);
@@ -672,7 +709,21 @@ void main() {
672
709
child: GridView (
673
710
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount (crossAxisCount: 3 ),
674
711
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
+ ],
676
727
),
677
728
),
678
729
);
0 commit comments