Commit 30784895 authored by Ali EP's avatar Ali EP Committed by Michael Goderbauer

Fixes crossAxisSpacing overflow in RTL (#27945)

parent d1136e31
......@@ -207,7 +207,7 @@ class SliverGridRegularTileLayout extends SliverGridLayout {
double _getOffsetFromStartInCrossAxis(double crossAxisStart) {
if (reverseCrossAxis)
return crossAxisCount * crossAxisStride - crossAxisStart - childCrossAxisExtent;
return crossAxisCount * crossAxisStride - crossAxisStart - childCrossAxisExtent - (crossAxisStride - childCrossAxisExtent);
return crossAxisStart;
}
......
......@@ -536,4 +536,32 @@ void main() {
expect(tester.getTopLeft(find.byKey(target)), const Offset(600.0, 0.0));
expect(tester.getBottomRight(find.byKey(target)), const Offset(800.0, 200.0));
});
testWidgets('GridView crossAxisSpacing', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/27151.
final Key target = UniqueKey();
Widget build(TextDirection textDirection) {
return Directionality(
textDirection: textDirection,
child: GridView.count(
crossAxisCount: 4,
crossAxisSpacing: 8.0,
children: <Widget>[
Container(key: target),
],
),
);
}
await tester.pumpWidget(build(TextDirection.ltr));
expect(tester.getTopLeft(find.byKey(target)), Offset.zero);
expect(tester.getBottomRight(find.byKey(target)), const Offset(194.0, 194.0));
await tester.pumpWidget(build(TextDirection.rtl));
expect(tester.getTopLeft(find.byKey(target)), const Offset(606.0, 0.0));
expect(tester.getBottomRight(find.byKey(target)), const Offset(800.0, 194.0));
});
}
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