Unverified Commit 13fe079b authored by chunhtai's avatar chunhtai Committed by GitHub

fixes preceision error during SliverGridRegularTileLayout (#74851)

parent 6bd54753
......@@ -194,7 +194,7 @@ class SliverGridRegularTileLayout extends SliverGridLayout {
@override
int getMinChildIndexForScrollOffset(double scrollOffset) {
return mainAxisStride > 0.0 ? crossAxisCount * (scrollOffset ~/ mainAxisStride) : 0;
return mainAxisStride > precisionErrorTolerance ? crossAxisCount * (scrollOffset ~/ mainAxisStride) : 0;
}
@override
......
......@@ -315,6 +315,30 @@ void main() {
expect(find.text('4'), findsNothing);
});
testWidgets('SliverGridRegularTileLayout - can handle close to zero mainAxisStride', (WidgetTester tester) async {
const SliverGridDelegateWithMaxCrossAxisExtent delegate = SliverGridDelegateWithMaxCrossAxisExtent(
childAspectRatio: 1e300,
maxCrossAxisExtent: 500.0,
);
final SliverGridLayout layout = delegate.getLayout(
const SliverConstraints(
axisDirection: AxisDirection.down,
growthDirection: GrowthDirection.forward,
userScrollDirection: ScrollDirection.forward,
scrollOffset: 100.0,
precedingScrollExtent: 0.0,
overlap: 0.0,
remainingPaintExtent: 0.0,
crossAxisExtent: 500,
crossAxisDirection: AxisDirection.right,
viewportMainAxisExtent: 100.0,
remainingCacheExtent: 0.0,
cacheOrigin: 0.0,
)
);
expect(layout.getMinChildIndexForScrollOffset(1000.0), 0.0);
});
testWidgets('GridView - change maxChildCrossAxisExtent', (WidgetTester tester) async {
final List<int> log = <int>[];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment