Fixes crossAxisSpacing overflow in RTL (#27945)
This commit is contained in:
parent
d1136e3109
commit
307848953f
@ -207,7 +207,7 @@ class SliverGridRegularTileLayout extends SliverGridLayout {
|
|||||||
|
|
||||||
double _getOffsetFromStartInCrossAxis(double crossAxisStart) {
|
double _getOffsetFromStartInCrossAxis(double crossAxisStart) {
|
||||||
if (reverseCrossAxis)
|
if (reverseCrossAxis)
|
||||||
return crossAxisCount * crossAxisStride - crossAxisStart - childCrossAxisExtent;
|
return crossAxisCount * crossAxisStride - crossAxisStart - childCrossAxisExtent - (crossAxisStride - childCrossAxisExtent);
|
||||||
return crossAxisStart;
|
return crossAxisStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,4 +536,32 @@ void main() {
|
|||||||
expect(tester.getTopLeft(find.byKey(target)), const Offset(600.0, 0.0));
|
expect(tester.getTopLeft(find.byKey(target)), const Offset(600.0, 0.0));
|
||||||
expect(tester.getBottomRight(find.byKey(target)), const Offset(800.0, 200.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));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user