Reverts: flutter/flutter#148470 Initiated by: eyebrowsoffire Reason for reverting: Unit test failures closing the tree. Original PR Author: hello-coder-xu Reviewed By: {QuncCccccc, Piinks} This change reverts the following previous change: * sliverGridDelegate mainAxisExtent add assert,Avoid incorrect use * Fixes https://github.com/flutter/flutter/issues/138871
This commit is contained in:
parent
af5a1a9e11
commit
886de22182
@ -348,8 +348,7 @@ class SliverGridDelegateWithFixedCrossAxisCount extends SliverGridDelegate {
|
|||||||
}) : assert(crossAxisCount > 0),
|
}) : assert(crossAxisCount > 0),
|
||||||
assert(mainAxisSpacing >= 0),
|
assert(mainAxisSpacing >= 0),
|
||||||
assert(crossAxisSpacing >= 0),
|
assert(crossAxisSpacing >= 0),
|
||||||
assert(childAspectRatio > 0),
|
assert(childAspectRatio > 0);
|
||||||
assert(mainAxisExtent == null || mainAxisExtent >= 0);
|
|
||||||
|
|
||||||
/// The number of children in the cross axis.
|
/// The number of children in the cross axis.
|
||||||
final int crossAxisCount;
|
final int crossAxisCount;
|
||||||
@ -447,8 +446,7 @@ class SliverGridDelegateWithMaxCrossAxisExtent extends SliverGridDelegate {
|
|||||||
}) : assert(maxCrossAxisExtent > 0),
|
}) : assert(maxCrossAxisExtent > 0),
|
||||||
assert(mainAxisSpacing >= 0),
|
assert(mainAxisSpacing >= 0),
|
||||||
assert(crossAxisSpacing >= 0),
|
assert(crossAxisSpacing >= 0),
|
||||||
assert(childAspectRatio > 0),
|
assert(childAspectRatio > 0);
|
||||||
assert(mainAxisExtent == null || mainAxisExtent >= 0);
|
|
||||||
|
|
||||||
/// The maximum extent of tiles in the cross axis.
|
/// The maximum extent of tiles in the cross axis.
|
||||||
///
|
///
|
||||||
|
@ -898,53 +898,4 @@ void main() {
|
|||||||
expect(controller.position.maxScrollExtent, 472.0);
|
expect(controller.position.maxScrollExtent, 472.0);
|
||||||
expect(controller.position.pixels, 472.0);
|
expect(controller.position.pixels, 472.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('SliverGridDelegate mainAxisExtent add assert', (WidgetTester tester) async {
|
|
||||||
Widget buildGridView(SliverGridDelegate delegate) {
|
|
||||||
return Directionality(
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
child: GridView.builder(
|
|
||||||
gridDelegate: delegate,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return Container(
|
|
||||||
height: 50,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text('$index'),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: 50,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(
|
|
||||||
() => tester.pumpWidget(buildGridView(SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 3,
|
|
||||||
mainAxisSpacing: 8,
|
|
||||||
crossAxisSpacing: 8,
|
|
||||||
mainAxisExtent: -100,
|
|
||||||
))),
|
|
||||||
throwsA(isAssertionError.having(
|
|
||||||
(AssertionError e) => e.toString(),
|
|
||||||
'.toString()',
|
|
||||||
contains("'mainAxisExtent == null || mainAxisExtent >= 0': is not true."),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
() => tester.pumpWidget(buildGridView(SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
maxCrossAxisExtent: 100,
|
|
||||||
mainAxisSpacing: 8,
|
|
||||||
crossAxisSpacing: 8,
|
|
||||||
mainAxisExtent: -100,
|
|
||||||
))),
|
|
||||||
throwsA(isAssertionError.having(
|
|
||||||
(AssertionError e) => e.toString(),
|
|
||||||
'.toString()',
|
|
||||||
contains("'mainAxisExtent == null || mainAxisExtent >= 0': is not true."),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user