@@ -904,35 +904,7 @@ void main() {
904904 'SliverGridDelegateWithFixedCrossAxisCount mainAxisExtent corrected' ,
905905 (WidgetTester tester) async {
906906 // Regression test for https://github.com/flutter/flutter/issues/138871
907- const SliverGridDelegateWithFixedCrossAxisCount delegate =
908- SliverGridDelegateWithFixedCrossAxisCount (
909- crossAxisCount: 3 ,
910- mainAxisSpacing: 8 ,
911- crossAxisSpacing: 8 ,
912- mainAxisExtent: - 100 ,
913- );
914-
915- final SliverGridRegularTileLayout sliverGridRegularTileLayout =
916- delegate.getLayout (
917- const SliverConstraints (
918- axisDirection: AxisDirection .down,
919- growthDirection: GrowthDirection .forward,
920- userScrollDirection: ScrollDirection .forward,
921- scrollOffset: 100.0 ,
922- precedingScrollExtent: 0.0 ,
923- overlap: 0.0 ,
924- remainingPaintExtent: 0.0 ,
925- crossAxisExtent: 500 ,
926- crossAxisDirection: AxisDirection .right,
927- viewportMainAxisExtent: 100.0 ,
928- remainingCacheExtent: 0.0 ,
929- cacheOrigin: 0.0 ,
930- ),
931- ) as SliverGridRegularTileLayout ;
932-
933- expect (sliverGridRegularTileLayout.childMainAxisExtent, 0 );
934-
935- Widget build (double mainAxisExtent) {
907+ Widget buildGridView (double mainAxisExtent) {
936908 return Directionality (
937909 textDirection: TextDirection .ltr,
938910 child: GridView .builder (
@@ -954,50 +926,17 @@ void main() {
954926 );
955927 }
956928
957- double mainAxisExtent = 100 ;
958- await tester.pumpWidget (build (mainAxisExtent));
959-
960- expect (tester.takeException (), isNull);
961-
962- mainAxisExtent = - 100 ;
963- await tester.pumpWidget (build (mainAxisExtent));
964-
965- expect (tester.takeException (), isNull);
929+ expect (
930+ () => tester.pumpWidget (buildGridView (- 100 )),
931+ throwsA (isA <AssertionError >()),
932+ );
966933 });
967934
968935 testWidgets (
969936 'SliverGridDelegateWithMaxCrossAxisExtent mainAxisExtent corrected' ,
970937 (WidgetTester tester) async {
971938 // Regression test for https://github.com/flutter/flutter/issues/138871
972- const SliverGridDelegateWithMaxCrossAxisExtent delegate =
973- SliverGridDelegateWithMaxCrossAxisExtent (
974- maxCrossAxisExtent: 100 ,
975- mainAxisSpacing: 8 ,
976- crossAxisSpacing: 8 ,
977- mainAxisExtent: - 100 ,
978- );
979-
980- final SliverGridRegularTileLayout sliverGridRegularTileLayout =
981- delegate.getLayout (
982- const SliverConstraints (
983- axisDirection: AxisDirection .down,
984- growthDirection: GrowthDirection .forward,
985- userScrollDirection: ScrollDirection .forward,
986- scrollOffset: 100.0 ,
987- precedingScrollExtent: 0.0 ,
988- overlap: 0.0 ,
989- remainingPaintExtent: 0.0 ,
990- crossAxisExtent: 500 ,
991- crossAxisDirection: AxisDirection .right,
992- viewportMainAxisExtent: 100.0 ,
993- remainingCacheExtent: 0.0 ,
994- cacheOrigin: 0.0 ,
995- ),
996- ) as SliverGridRegularTileLayout ;
997-
998- expect (sliverGridRegularTileLayout.childMainAxisExtent, 0 );
999-
1000- Widget build (double mainAxisExtent) {
939+ Widget buildGridView (double mainAxisExtent) {
1001940 return Directionality (
1002941 textDirection: TextDirection .ltr,
1003942 child: GridView .builder (
@@ -1019,14 +958,9 @@ void main() {
1019958 );
1020959 }
1021960
1022- double mainAxisExtent = 100 ;
1023- await tester.pumpWidget (build (mainAxisExtent));
1024-
1025- expect (tester.takeException (), isNull);
1026-
1027- mainAxisExtent = - 100 ;
1028- await tester.pumpWidget (build (mainAxisExtent));
1029-
1030- expect (tester.takeException (), isNull);
961+ expect (
962+ () => tester.pumpWidget (buildGridView (- 100 )),
963+ throwsA (isA <AssertionError >()),
964+ );
1031965 });
1032966}
0 commit comments