RTL: Padding, Flex (#11709)

* Introduce a Directionality inherited widget which sets the ambient LTR vs RTL mode (defaulting to null, which means you cannot use directionality-influenced values).

* Make it possible to configure Padding (including Container.padding and Container.margin) using a directionality-agnostic EdgeInsets variant.

* Provide textDirection and verticalDirection controls on Row and Column to make them RTL-aware.

* Introduce a variant of FractionalOffset based on the EdgeInsets variant. Not yet actually used.

* Fix all the tests that depended on Row defaulting to LTR.
This commit is contained in:
Ian Hickson
2017-08-28 12:50:24 -07:00
committed by GitHub
parent 3dd1a05a8a
commit f235a2c104
59 changed files with 4926 additions and 1638 deletions

View File

@@ -140,33 +140,42 @@ void main() {
group('find.descendant', () {
testWidgets('finds one descendant', (WidgetTester tester) async {
await tester.pumpWidget(new Row(children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')])
]));
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
],
));
expect(find.descendant(
of: find.widgetWithText(Row, 'foo'),
matching: find.text('bar')
matching: find.text('bar'),
), findsOneWidget);
});
testWidgets('finds two descendants with different ancestors', (WidgetTester tester) async {
await tester.pumpWidget(new Row(children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
]));
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
],
));
expect(find.descendant(
of: find.widgetWithText(Column, 'foo'),
matching: find.text('bar')
matching: find.text('bar'),
), findsNWidgets(2));
});
testWidgets('fails with a descriptive message', (WidgetTester tester) async {
await tester.pumpWidget(new Row(children: <Widget>[
new Column(children: <Text>[const Text('foo')]),
const Text('bar')
]));
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: <Text>[const Text('foo')]),
const Text('bar'),
],
));
TestFailure failure;
try {
@@ -186,9 +195,12 @@ void main() {
});
testWidgets('Root not matched by default', (WidgetTester tester) async {
await tester.pumpWidget(new Row(children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')])
]));
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
],
));
expect(find.descendant(
of: find.widgetWithText(Row, 'foo'),
@@ -197,9 +209,12 @@ void main() {
});
testWidgets('Match the root', (WidgetTester tester) async {
await tester.pumpWidget(new Row(children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')])
]));
await tester.pumpWidget(new Row(
textDirection: TextDirection.ltr,
children: <Widget>[
new Column(children: <Text>[const Text('foo'), const Text('bar')]),
],
));
expect(find.descendant(
of: find.widgetWithText(Row, 'foo'),