diff --git a/examples/layers/rendering/touch_input.dart b/examples/layers/rendering/touch_input.dart index 891e509fea..a1bed9e667 100644 --- a/examples/layers/rendering/touch_input.dart +++ b/examples/layers/rendering/touch_input.dart @@ -112,6 +112,7 @@ void main() { // The bottom later is our RenderDots object, and on top of that we show the // text. final RenderStack stack = new RenderStack( + textDirection: TextDirection.ltr, children: [ new RenderDots(), paragraph, diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index abc3c8f5c3..45a240bf35 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -297,16 +297,19 @@ class RenderStack extends RenderBox /// top left corners. RenderStack({ List children, - FractionalOffset alignment: FractionalOffset.topLeft, + FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart, + @required TextDirection textDirection, StackFit fit: StackFit.loose, - Overflow overflow: Overflow.clip + Overflow overflow: Overflow.clip, }) : assert(alignment != null), assert(fit != null), assert(overflow != null), _alignment = alignment, + _textDirection = textDirection, _fit = fit, _overflow = overflow { addAll(children); + _applyUpdate(); } bool _hasVisualOverflow = false; @@ -317,19 +320,40 @@ class RenderStack extends RenderBox child.parentData = new StackParentData(); } + // The resolved absolute insets. + FractionalOffset _resolvedAlignment; + + void _applyUpdate() { + final FractionalOffset resolvedAlignment = alignment.resolve(textDirection); + if (_resolvedAlignment != resolvedAlignment) { + _resolvedAlignment = resolvedAlignment; + markNeedsLayout(); + } + } + /// How to align the non-positioned children in the stack. /// /// The non-positioned children are placed relative to each other such that /// the points determined by [alignment] are co-located. For example, if the /// [alignment] is [FractionalOffset.topLeft], then the top left corner of /// each non-positioned child will be located at the same global coordinate. - FractionalOffset get alignment => _alignment; - FractionalOffset _alignment; - set alignment(FractionalOffset value) { + FractionalOffsetGeometry get alignment => _alignment; + FractionalOffsetGeometry _alignment; + set alignment(FractionalOffsetGeometry value) { assert(value != null); if (_alignment != value) { _alignment = value; - markNeedsLayout(); + _applyUpdate(); + } + } + + /// The text direction with which to resolve [alignment]. + TextDirection get textDirection => _textDirection; + TextDirection _textDirection; + set textDirection(TextDirection value) { + if (_textDirection != value) { + _textDirection = value; + _applyUpdate(); } } @@ -455,7 +479,7 @@ class RenderStack extends RenderBox final StackParentData childParentData = child.parentData; if (!childParentData.isPositioned) { - childParentData.offset = alignment.alongOffset(size - child.size); + childParentData.offset = _resolvedAlignment.alongOffset(size - child.size); } else { BoxConstraints childConstraints = const BoxConstraints(); @@ -526,7 +550,8 @@ class RenderStack extends RenderBox @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('alignment', alignment)); + description.add(new DiagnosticsProperty('alignment', alignment)); + description.add(new EnumProperty('textDirection', textDirection)); description.add(new EnumProperty('fit', fit)); description.add(new EnumProperty('overflow', overflow)); } @@ -543,11 +568,13 @@ class RenderIndexedStack extends RenderStack { /// If the [index] parameter is null, nothing is displayed. RenderIndexedStack({ List children, - FractionalOffset alignment: FractionalOffset.topLeft, - int index: 0 + FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart, + @required TextDirection textDirection, + int index: 0, }) : _index = index, super( children: children, - alignment: alignment + alignment: alignment, + textDirection: textDirection, ); @override diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 250f4b5e82..fd66107136 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -2193,7 +2193,8 @@ class Stack extends MultiChildRenderObjectWidget { /// top left corners. Stack({ Key key, - this.alignment: FractionalOffset.topLeft, + this.alignment: FractionalOffsetDirectional.topStart, + this.textDirection, this.fit: StackFit.loose, this.overflow: Overflow.clip, List children: const [], @@ -2205,7 +2206,12 @@ class Stack extends MultiChildRenderObjectWidget { /// the points determined by [alignment] are co-located. For example, if the /// [alignment] is [FractionalOffset.topLeft], then the top left corner of /// each non-positioned child will be located at the same global coordinate. - final FractionalOffset alignment; + final FractionalOffsetGeometry alignment; + + /// The text direction with which to resolve [alignment]. + /// + /// Defaults to the ambient [Directionality]. + final TextDirection textDirection; /// How to size the non-positioned children in the stack. /// @@ -2224,6 +2230,7 @@ class Stack extends MultiChildRenderObjectWidget { RenderStack createRenderObject(BuildContext context) { return new RenderStack( alignment: alignment, + textDirection: textDirection ?? Directionality.of(context), fit: fit, overflow: overflow, ); @@ -2233,6 +2240,7 @@ class Stack extends MultiChildRenderObjectWidget { void updateRenderObject(BuildContext context, RenderStack renderObject) { renderObject ..alignment = alignment + ..textDirection = textDirection ?? Directionality.of(context) ..fit = fit ..overflow = overflow; } @@ -2240,7 +2248,8 @@ class Stack extends MultiChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('alignment', alignment)); + description.add(new DiagnosticsProperty('alignment', alignment)); + description.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); description.add(new EnumProperty('fit', fit)); description.add(new EnumProperty('overflow', overflow)); } @@ -2260,23 +2269,31 @@ class IndexedStack extends Stack { /// The [index] argument must not be null. IndexedStack({ Key key, - FractionalOffset alignment: FractionalOffset.topLeft, + FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart, + TextDirection textDirection, StackFit sizing: StackFit.loose, this.index: 0, List children: const [], - }) : super(key: key, alignment: alignment, fit: sizing, children: children); + }) : super(key: key, alignment: alignment, textDirection: textDirection, fit: sizing, children: children); /// The index of the child to show. final int index; @override - RenderIndexedStack createRenderObject(BuildContext context) => new RenderIndexedStack(index: index, alignment: alignment); + RenderIndexedStack createRenderObject(BuildContext context) { + return new RenderIndexedStack( + index: index, + alignment: alignment, + textDirection: textDirection ?? Directionality.of(context), + ); + } @override void updateRenderObject(BuildContext context, RenderIndexedStack renderObject) { renderObject ..index = index - ..alignment = alignment; + ..alignment = alignment + ..textDirection = textDirection ?? Directionality.of(context); } } diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 07c3d3fcf4..fbeac1bda6 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -115,18 +115,21 @@ void main() { } Widget build() { - return new Navigator( - initialRoute: '/', - onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute( - settings: settings, - builder: (BuildContext context) { - return new Material( - child: buildFrame(value: 'one', onChanged: didChangeValue), - ); - }, - ); - } + return new Directionality( + textDirection: TextDirection.ltr, + child: new Navigator( + initialRoute: '/', + onGenerateRoute: (RouteSettings settings) { + return new MaterialPageRoute( + settings: settings, + builder: (BuildContext context) { + return new Material( + child: buildFrame(value: 'one', onChanged: didChangeValue), + ); + }, + ); + }, + ), ); } diff --git a/packages/flutter/test/rendering/stack_test.dart b/packages/flutter/test/rendering/stack_test.dart index 516359580e..4ce2e61286 100644 --- a/packages/flutter/test/rendering/stack_test.dart +++ b/packages/flutter/test/rendering/stack_test.dart @@ -26,7 +26,10 @@ void main() { ), ); - final RenderBox stack = new RenderStack(children: [red, green]); + final RenderBox stack = new RenderStack( + textDirection: TextDirection.ltr, + children: [red, green], + ); final StackParentData greenParentData = green.parentData; greenParentData ..top = 0.0 @@ -59,8 +62,9 @@ void main() { additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)) ); final RenderBox stack = new RenderIndexedStack( - children: [child1, child2, child3], index: 1, + textDirection: TextDirection.ltr, + children: [child1, child2, child3], ); final List vistedChildren = []; diff --git a/packages/flutter/test/widgets/animated_cross_fade_test.dart b/packages/flutter/test/widgets/animated_cross_fade_test.dart index 7dd78247cb..8c20294c4e 100644 --- a/packages/flutter/test/widgets/animated_cross_fade_test.dart +++ b/packages/flutter/test/widgets/animated_cross_fade_test.dart @@ -10,18 +10,21 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('AnimatedCrossFade test', (WidgetTester tester) async { await tester.pumpWidget( - const Center( - child: const AnimatedCrossFade( - firstChild: const SizedBox( - width: 100.0, - height: 100.0, + const Directionality( + textDirection: TextDirection.ltr, + child: const Center( + child: const AnimatedCrossFade( + firstChild: const SizedBox( + width: 100.0, + height: 100.0, + ), + secondChild: const SizedBox( + width: 200.0, + height: 200.0, + ), + duration: const Duration(milliseconds: 200), + crossFadeState: CrossFadeState.showFirst, ), - secondChild: const SizedBox( - width: 200.0, - height: 200.0, - ), - duration: const Duration(milliseconds: 200), - crossFadeState: CrossFadeState.showFirst, ), ), ); @@ -32,18 +35,21 @@ void main() { expect(box.size.height, equals(100.0)); await tester.pumpWidget( - const Center( - child: const AnimatedCrossFade( - firstChild: const SizedBox( - width: 100.0, - height: 100.0, + const Directionality( + textDirection: TextDirection.ltr, + child: const Center( + child: const AnimatedCrossFade( + firstChild: const SizedBox( + width: 100.0, + height: 100.0, + ), + secondChild: const SizedBox( + width: 200.0, + height: 200.0, + ), + duration: const Duration(milliseconds: 200), + crossFadeState: CrossFadeState.showSecond, ), - secondChild: const SizedBox( - width: 200.0, - height: 200.0, - ), - duration: const Duration(milliseconds: 200), - crossFadeState: CrossFadeState.showSecond, ), ), ); @@ -58,18 +64,21 @@ void main() { testWidgets('AnimatedCrossFade test showSecond', (WidgetTester tester) async { await tester.pumpWidget( - const Center( - child: const AnimatedCrossFade( - firstChild: const SizedBox( - width: 100.0, - height: 100.0, + const Directionality( + textDirection: TextDirection.ltr, + child: const Center( + child: const AnimatedCrossFade( + firstChild: const SizedBox( + width: 100.0, + height: 100.0, + ), + secondChild: const SizedBox( + width: 200.0, + height: 200.0, + ), + duration: const Duration(milliseconds: 200), + crossFadeState: CrossFadeState.showSecond, ), - secondChild: const SizedBox( - width: 200.0, - height: 200.0, - ), - duration: const Duration(milliseconds: 200), - crossFadeState: CrossFadeState.showSecond, ), ), ); @@ -85,41 +94,47 @@ void main() { final Key secondKey = new UniqueKey(); await tester.pumpWidget( - new Center( - child: new AnimatedCrossFade( - alignment: FractionalOffset.bottomRight, - firstChild: new SizedBox( - key: firstKey, - width: 100.0, - height: 100.0, + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new AnimatedCrossFade( + alignment: FractionalOffset.bottomRight, + firstChild: new SizedBox( + key: firstKey, + width: 100.0, + height: 100.0, + ), + secondChild: new SizedBox( + key: secondKey, + width: 200.0, + height: 200.0, + ), + duration: const Duration(milliseconds: 200), + crossFadeState: CrossFadeState.showFirst, ), - secondChild: new SizedBox( - key: secondKey, - width: 200.0, - height: 200.0, - ), - duration: const Duration(milliseconds: 200), - crossFadeState: CrossFadeState.showFirst, ), ), ); await tester.pumpWidget( - new Center( - child: new AnimatedCrossFade( - alignment: FractionalOffset.bottomRight, - firstChild: new SizedBox( - key: firstKey, - width: 100.0, - height: 100.0, + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new AnimatedCrossFade( + alignment: FractionalOffset.bottomRight, + firstChild: new SizedBox( + key: firstKey, + width: 100.0, + height: 100.0, + ), + secondChild: new SizedBox( + key: secondKey, + width: 200.0, + height: 200.0, + ), + duration: const Duration(milliseconds: 200), + crossFadeState: CrossFadeState.showSecond, ), - secondChild: new SizedBox( - key: secondKey, - width: 200.0, - height: 200.0, - ), - duration: const Duration(milliseconds: 200), - crossFadeState: CrossFadeState.showSecond, ), ), ); @@ -249,11 +264,14 @@ void main() { }); Widget crossFadeWithWatcher({bool towardsSecond: false}) { - return new AnimatedCrossFade( - firstChild: const _TickerWatchingWidget(), - secondChild: new Container(), - crossFadeState: towardsSecond ? CrossFadeState.showSecond : CrossFadeState.showFirst, - duration: const Duration(milliseconds: 50), + return new Directionality( + textDirection: TextDirection.ltr, + child: new AnimatedCrossFade( + firstChild: const _TickerWatchingWidget(), + secondChild: new Container(), + crossFadeState: towardsSecond ? CrossFadeState.showSecond : CrossFadeState.showFirst, + duration: const Duration(milliseconds: 50), + ), ); } @@ -301,30 +319,45 @@ void main() { }); testWidgets('AnimatedCrossFade.layoutBuilder', (WidgetTester tester) async { - await tester.pumpWidget(const AnimatedCrossFade( - firstChild: const Text('AAA', textDirection: TextDirection.ltr), - secondChild: const Text('BBB', textDirection: TextDirection.ltr), - crossFadeState: CrossFadeState.showFirst, - duration: const Duration(milliseconds: 50), - )); + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: const AnimatedCrossFade( + firstChild: const Text('AAA', textDirection: TextDirection.ltr), + secondChild: const Text('BBB', textDirection: TextDirection.ltr), + crossFadeState: CrossFadeState.showFirst, + duration: const Duration(milliseconds: 50), + ), + ), + ); expect(find.text('AAA'), findsOneWidget); expect(find.text('BBB'), findsOneWidget); - await tester.pumpWidget(new AnimatedCrossFade( - firstChild: const Text('AAA', textDirection: TextDirection.ltr), - secondChild: const Text('BBB', textDirection: TextDirection.ltr), - crossFadeState: CrossFadeState.showFirst, - duration: const Duration(milliseconds: 50), - layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a, - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new AnimatedCrossFade( + firstChild: const Text('AAA', textDirection: TextDirection.ltr), + secondChild: const Text('BBB', textDirection: TextDirection.ltr), + crossFadeState: CrossFadeState.showFirst, + duration: const Duration(milliseconds: 50), + layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a, + ), + ), + ); expect(find.text('AAA'), findsOneWidget); expect(find.text('BBB'), findsNothing); - await tester.pumpWidget(new AnimatedCrossFade( - firstChild: const Text('AAA', textDirection: TextDirection.ltr), - secondChild: const Text('BBB', textDirection: TextDirection.ltr), - crossFadeState: CrossFadeState.showSecond, - duration: const Duration(milliseconds: 50), - layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a, - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new AnimatedCrossFade( + firstChild: const Text('AAA', textDirection: TextDirection.ltr), + secondChild: const Text('BBB', textDirection: TextDirection.ltr), + crossFadeState: CrossFadeState.showSecond, + duration: const Duration(milliseconds: 50), + layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a, + ), + ), + ); expect(find.text('BBB'), findsOneWidget); expect(find.text('AAA'), findsNothing); }); diff --git a/packages/flutter/test/widgets/animated_positioned_test.dart b/packages/flutter/test/widgets/animated_positioned_test.dart index 61debf3072..70f534cc8c 100644 --- a/packages/flutter/test/widgets/animated_positioned_test.dart +++ b/packages/flutter/test/widgets/animated_positioned_test.dart @@ -27,6 +27,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), @@ -50,6 +51,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), @@ -110,6 +112,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), @@ -133,6 +136,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), @@ -156,6 +160,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), @@ -190,6 +195,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), @@ -213,6 +219,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new AnimatedPositioned( child: new Container(key: key), diff --git a/packages/flutter/test/widgets/app_overrides_test.dart b/packages/flutter/test/widgets/app_overrides_test.dart index 44d0aac74c..e4ca97889b 100644 --- a/packages/flutter/test/widgets/app_overrides_test.dart +++ b/packages/flutter/test/widgets/app_overrides_test.dart @@ -26,12 +26,17 @@ class TestRoute extends PageRoute { } Future pumpApp(WidgetTester tester) async { - await tester.pumpWidget(new WidgetsApp( - color: const Color(0xFF333333), - onGenerateRoute: (RouteSettings settings) { - return new TestRoute(settings: settings, child: new Container()); - }, - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new WidgetsApp( + color: const Color(0xFF333333), + onGenerateRoute: (RouteSettings settings) { + return new TestRoute(settings: settings, child: new Container()); + }, + ), + ), + ); } void main() { diff --git a/packages/flutter/test/widgets/composited_transform_test.dart b/packages/flutter/test/widgets/composited_transform_test.dart index e293b8c228..89cff1b00a 100644 --- a/packages/flutter/test/widgets/composited_transform_test.dart +++ b/packages/flutter/test/widgets/composited_transform_test.dart @@ -11,25 +11,28 @@ void main() { final LayerLink link = new LayerLink(); final GlobalKey key = new GlobalKey(); await tester.pumpWidget( - new Stack( - children: [ - new Positioned( - left: 123.0, - top: 456.0, - child: new CompositedTransformTarget( - link: link, - child: new Container(height: 10.0, width: 10.0), + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + left: 123.0, + top: 456.0, + child: new CompositedTransformTarget( + link: link, + child: new Container(height: 10.0, width: 10.0), + ), ), - ), - new Positioned( - left: 787.0, - top: 343.0, - child: new CompositedTransformFollower( - link: link, - child: new Container(key: key, height: 10.0, width: 10.0), + new Positioned( + left: 787.0, + top: 343.0, + child: new CompositedTransformFollower( + link: link, + child: new Container(key: key, height: 10.0, width: 10.0), + ), ), - ), - ], + ], + ), ), ); final RenderBox box = key.currentContext.findRenderObject(); @@ -41,31 +44,34 @@ void main() { final GlobalKey key1 = new GlobalKey(); final GlobalKey key2 = new GlobalKey(); await tester.pumpWidget( - new Stack( - children: [ - new Positioned( - top: 123.0, - left: 456.0, - child: new Transform.rotate( - angle: 1.0, // radians - child: new CompositedTransformTarget( - link: link, - child: new Container(key: key1, height: 10.0, width: 10.0), + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + top: 123.0, + left: 456.0, + child: new Transform.rotate( + angle: 1.0, // radians + child: new CompositedTransformTarget( + link: link, + child: new Container(key: key1, height: 10.0, width: 10.0), + ), ), ), - ), - new Positioned( - top: 787.0, - left: 343.0, - child: new Transform.rotate( - angle: -0.3, // radians - child: new CompositedTransformFollower( - link: link, - child: new Container(key: key2, height: 10.0, width: 10.0), + new Positioned( + top: 787.0, + left: 343.0, + child: new Transform.rotate( + angle: -0.3, // radians + child: new CompositedTransformFollower( + link: link, + child: new Container(key: key2, height: 10.0, width: 10.0), + ), ), ), - ), - ], + ], + ), ), ); final RenderBox box1 = key1.currentContext.findRenderObject(); @@ -81,43 +87,46 @@ void main() { final GlobalKey key1 = new GlobalKey(); final GlobalKey key2 = new GlobalKey(); await tester.pumpWidget( - new Stack( - children: [ - new Positioned( - top: 123.0, - left: 456.0, - child: new Transform.rotate( - angle: 1.0, // radians - child: new CompositedTransformTarget( - link: link, - child: new Container(key: key1, height: 10.0, width: 10.0), + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + top: 123.0, + left: 456.0, + child: new Transform.rotate( + angle: 1.0, // radians + child: new CompositedTransformTarget( + link: link, + child: new Container(key: key1, height: 10.0, width: 10.0), + ), ), ), - ), - new Positioned( - top: 787.0, - left: 343.0, - child: new Transform.rotate( - angle: -0.3, // radians - child: new Padding( - padding: const EdgeInsets.all(20.0), - child: new CompositedTransformFollower( - link: new LayerLink(), - child: new Transform( - transform: new Matrix4.skew(0.9, 1.1), - child: new Padding( - padding: const EdgeInsets.all(20.0), - child: new CompositedTransformFollower( - link: link, - child: new Container(key: key2, height: 10.0, width: 10.0), + new Positioned( + top: 787.0, + left: 343.0, + child: new Transform.rotate( + angle: -0.3, // radians + child: new Padding( + padding: const EdgeInsets.all(20.0), + child: new CompositedTransformFollower( + link: new LayerLink(), + child: new Transform( + transform: new Matrix4.skew(0.9, 1.1), + child: new Padding( + padding: const EdgeInsets.all(20.0), + child: new CompositedTransformFollower( + link: link, + child: new Container(key: key2, height: 10.0, width: 10.0), + ), ), ), ), ), ), ), - ), - ], + ], + ), ), ); final RenderBox box1 = key1.currentContext.findRenderObject(); @@ -135,26 +144,29 @@ void main() { final GlobalKey key3 = new GlobalKey(); bool _tapped = false; await tester.pumpWidget( - new Stack( - children: [ - new Positioned( - left: 123.0, - top: 456.0, - child: new CompositedTransformTarget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + left: 123.0, + top: 456.0, + child: new CompositedTransformTarget( + link: link, + child: new Container(key: key1, height: 10.0, width: 10.0), + ), + ), + new CompositedTransformFollower( link: link, - child: new Container(key: key1, height: 10.0, width: 10.0), + child: new GestureDetector( + key: key2, + behavior: HitTestBehavior.opaque, + onTap: () { _tapped = true; }, + child: new Container(key: key3, height: 10.0, width: 10.0), + ), ), - ), - new CompositedTransformFollower( - link: link, - child: new GestureDetector( - key: key2, - behavior: HitTestBehavior.opaque, - onTap: () { _tapped = true; }, - child: new Container(key: key3, height: 10.0, width: 10.0), - ), - ), - ], + ], + ), ), ); final RenderBox box2 = key2.currentContext.findRenderObject(); diff --git a/packages/flutter/test/widgets/coordinates_test.dart b/packages/flutter/test/widgets/coordinates_test.dart index 7f6ac486b4..498c87237c 100644 --- a/packages/flutter/test/widgets/coordinates_test.dart +++ b/packages/flutter/test/widgets/coordinates_test.dart @@ -13,6 +13,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( top: 100.0, @@ -20,8 +21,8 @@ void main() { child: new SizedBox( key: keyA, width: 10.0, - height: 10.0 - ) + height: 10.0, + ), ), new Positioned( left: 100.0, @@ -29,11 +30,11 @@ void main() { child: new SizedBox( key: keyB, width: 20.0, - height: 10.0 - ) + height: 10.0, + ), ), - ] - ) + ], + ), ); final RenderBox boxA = tester.renderObject(find.byKey(keyA)); diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index 4e6acb2666..b521479c64 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -25,10 +25,10 @@ void main() { builder: (BuildContext context, List data, List rejects) { return new Container(height: 100.0, child: const Text('Target')); }, - onAccept: accepted.add + onAccept: accepted.add, ), - ] - ) + ], + ), )); expect(accepted, isEmpty); @@ -77,7 +77,7 @@ void main() { const Draggable( data: 1, child: const Text('Source'), - feedback: const Text('Dragging') + feedback: const Text('Dragging'), ), new Stack( children: [ @@ -86,22 +86,22 @@ void main() { onTap: () { events.add('tap'); }, - child: new Container(child: const Text('Button') - ) + child: new Container(child: const Text('Button'), + ), ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new IgnorePointer( - child: new Container(child: const Text('Target')) + child: new Container(child: const Text('Target')), ); }, onAccept: (int data) { events.add('drop'); }), - ] + ], ), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -171,9 +171,9 @@ void main() { onTap: () { events.add('tap'); }, - child: new Container(child: const Text('Button')) + child: new Container(child: const Text('Button')), ), - feedback: const Text('Dragging') + feedback: const Text('Dragging'), ), new DragTarget( builder: (BuildContext context, List data, List rejects) { @@ -181,10 +181,10 @@ void main() { }, onAccept: (int data) { events.add('drop'); - } + }, ), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -221,7 +221,7 @@ void main() { const LongPressDraggable( data: 1, child: const Text('Source'), - feedback: const Text('Dragging') + feedback: const Text('Dragging'), ), new DragTarget( builder: (BuildContext context, List data, List rejects) { @@ -229,10 +229,10 @@ void main() { }, onAccept: (int data) { events.add('drop'); - } + }, ), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -267,7 +267,7 @@ void main() { const Draggable( data: 1, child: const Text('Source'), - feedback: const Text('Dragging') + feedback: const Text('Dragging'), ), new DragTarget( builder: (BuildContext context, List data, List rejects) { @@ -275,10 +275,10 @@ void main() { }, onAccept: (int data) { events.add('drop'); - } + }, ), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -337,8 +337,8 @@ void main() { new Container(height: 500.0), new Container(height: 500.0), new Container(height: 500.0), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -444,8 +444,8 @@ void main() { new Container(width: 500.0), new Container(width: 500.0), new Container(width: 500.0), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -537,10 +537,10 @@ void main() { builder: (BuildContext context, List data, List rejects) { return new Container(height: 100.0, child: const Text('Target')); }, - onAccept: accepted.add + onAccept: accepted.add, ), - ] - ) + ], + ), )); expect(accepted, isEmpty); @@ -596,7 +596,7 @@ void main() { onDraggableCanceledCalled = true; onDraggableCanceledVelocity = velocity; onDraggableCanceledOffset = offset; - } + }, ), new DragTarget( builder: (BuildContext context, List data, List rejects) { @@ -605,10 +605,10 @@ void main() { child: const Text('Target') ); }, - onWillAccept: (int data) => false + onWillAccept: (int data) => false, ), - ] - ) + ], + ), )); expect(accepted, isEmpty); @@ -665,18 +665,18 @@ void main() { onDraggableCanceledCalled = true; onDraggableCanceledVelocity = velocity; onDraggableCanceledOffset = offset; - } + }, ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new Container( height: 100.0, - child: const Text('Target') + child: const Text('Target'), ); }, onWillAccept: (int data) => false), - ] - ) + ], + ), )); expect(accepted, isEmpty); @@ -712,19 +712,19 @@ void main() { feedback: const Text('Dragging'), onDragCompleted: () { onDragCompletedCalled = true; - } + }, ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new Container( height: 100.0, - child: const Text('Target') + child: const Text('Target'), ); }, - onWillAccept: (int data) => false + onWillAccept: (int data) => false, ), - ] - ) + ], + ), )); expect(accepted, isEmpty); @@ -776,16 +776,16 @@ void main() { feedback: const Text('Dragging'), onDragCompleted: () { onDragCompletedCalled = true; - } + }, ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new Container(height: 100.0, child: const Text('Target')); }, - onAccept: accepted.add + onAccept: accepted.add, ), - ] - ) + ], + ), )); expect(accepted, isEmpty); @@ -834,12 +834,12 @@ void main() { const Draggable( data: 1, child: const Text('IntSource'), - feedback: const Text('IntDragging') + feedback: const Text('IntDragging'), ), const Draggable( data: 1.0, child: const Text('DoubleSource'), - feedback: const Text('DoubleDragging') + feedback: const Text('DoubleDragging'), ), new Stack( children: [ @@ -848,27 +848,27 @@ void main() { return new IgnorePointer( child: new Container( height: 100.0, - child: const Text('Target1') - ) + child: const Text('Target1'), + ), ); }, - onAccept: acceptedInts.add + onAccept: acceptedInts.add, ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new IgnorePointer( child: new Container( height: 100.0, - child: const Text('Target2') - ) + child: const Text('Target2'), + ), ); }, - onAccept: acceptedDoubles.add + onAccept: acceptedDoubles.add, ), - ] - ) - ] - ) + ], + ), + ], + ), )); expect(acceptedInts, isEmpty); @@ -947,7 +947,7 @@ void main() { new Draggable( data: dragTargetData, child: const Text('Source'), - feedback: const Text('Dragging') + feedback: const Text('Dragging'), ), new Stack( children: [ @@ -956,26 +956,26 @@ void main() { return new IgnorePointer( child: new Container( height: 100.0, - child: const Text('Target1') - ) + child: const Text('Target1'), + ), ); - }, onAccept: acceptedDragTargetDatas.add + }, onAccept: acceptedDragTargetDatas.add, ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new IgnorePointer( child: new Container( height: 100.0, - child: const Text('Target2') - ) + child: const Text('Target2'), + ), ); }, - onAccept: acceptedExtendedDragTargetDatas.add + onAccept: acceptedExtendedDragTargetDatas.add, ), - ] - ) - ] - ) + ], + ), + ], + ), )); final Offset dragTargetLocation = tester.getCenter(find.text('Source')); @@ -1008,16 +1008,16 @@ void main() { data: 1, maxSimultaneousDrags: maxSimultaneousDrags, child: const Text('Source'), - feedback: const Text('Dragging') + feedback: const Text('Dragging'), ), new DragTarget( builder: (BuildContext context, List data, List rejects) { return new Container(height: 100.0, child: const Text('Target')); }, - onAccept: accepted.add + onAccept: accepted.add, ), - ] - ) + ], + ), ); } @@ -1109,27 +1109,32 @@ void main() { testWidgets('Draggable disposes recognizer', (WidgetTester tester) async { bool didTap = false; - await tester.pumpWidget(new Overlay( - initialEntries: [ - new OverlayEntry( - builder: (BuildContext context) => new GestureDetector( - onTap: () { - didTap = true; - }, - child: new Draggable( - child: new Container( - color: const Color(0xFFFFFF00), + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Overlay( + initialEntries: [ + new OverlayEntry( + builder: (BuildContext context) => new GestureDetector( + onTap: () { + didTap = true; + }, + child: new Draggable( + child: new Container( + color: const Color(0xFFFFFF00), + ), + feedback: new Container( + width: 100.0, + height: 100.0, + color: const Color(0xFFFF0000), + ), + ), ), - feedback: new Container( - width: 100.0, - height: 100.0, - color: const Color(0xFFFF0000), - ) - ) - ) - ) - ] - )); + ), + ], + ), + ), + ); await tester.startGesture(const Offset(10.0, 10.0)); expect(didTap, isFalse); @@ -1142,25 +1147,30 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/6128. testWidgets('Draggable plays nice with onTap', (WidgetTester tester) async { - await tester.pumpWidget(new Overlay( - initialEntries: [ - new OverlayEntry( - builder: (BuildContext context) => new GestureDetector( - onTap: () { /* registers a tap recognizer */ }, - child: new Draggable( - child: new Container( - color: const Color(0xFFFFFF00), + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Overlay( + initialEntries: [ + new OverlayEntry( + builder: (BuildContext context) => new GestureDetector( + onTap: () { /* registers a tap recognizer */ }, + child: new Draggable( + child: new Container( + color: const Color(0xFFFFFF00), + ), + feedback: new Container( + width: 100.0, + height: 100.0, + color: const Color(0xFFFF0000), + ), + ), ), - feedback: new Container( - width: 100.0, - height: 100.0, - color: const Color(0xFFFF0000), - ) - ) - ) - ) - ] - )); + ), + ], + ), + ), + ); final TestGesture firstGesture = await tester.startGesture(const Offset(10.0, 10.0), pointer: 24); final TestGesture secondGesture = await tester.startGesture(const Offset(10.0, 20.0), pointer: 25); @@ -1187,10 +1197,10 @@ void main() { }, onAccept: (int data) { events.add('drop'); - } + }, ), - ] - ) + ], + ), )); expect(events, isEmpty); @@ -1232,21 +1242,21 @@ void main() { final List accepted = []; await tester.pumpWidget(new MaterialApp( - home: new Column( - children: [ - const Draggable( - data: 1, - child: const Text('Source'), - feedback: const Text('Dragging') - ), - new DragTarget( - builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); - }, - onAccept: accepted.add - ), - ] - ) + home: new Column( + children: [ + const Draggable( + data: 1, + child: const Text('Source'), + feedback: const Text('Dragging') + ), + new DragTarget( + builder: (BuildContext context, List data, List rejects) { + return new Container(height: 100.0, child: const Text('Target')); + }, + onAccept: accepted.add, + ), + ], + ), )); expect(accepted, isEmpty); @@ -1264,16 +1274,16 @@ void main() { expect(find.text('Target'), findsOneWidget); await tester.pumpWidget(new MaterialApp( - home: new Column( - children: [ - new DragTarget( - builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); - }, - onAccept: accepted.add - ), - ] - ) + home: new Column( + children: [ + new DragTarget( + builder: (BuildContext context, List data, List rejects) { + return new Container(height: 100.0, child: const Text('Target')); + }, + onAccept: accepted.add, + ), + ], + ), )); expect(accepted, isEmpty); @@ -1336,34 +1346,39 @@ Future _testChildAnchorFeedbackPosition({WidgetTester tester, double top: final List accepted = []; int dragStartedCount = 0; - await tester.pumpWidget(new Stack(children: [ - new Positioned( - left: left, - top: top, - right: 0.0, - bottom: 0.0, - child: new MaterialApp( - home: new Column( - children: [ - new Draggable( - data: 1, - child: const Text('Source'), - feedback: const Text('Dragging'), - onDragStarted: () { - ++dragStartedCount; - }, + await tester.pumpWidget( + new Stack( + textDirection: TextDirection.ltr, + children: [ + new Positioned( + left: left, + top: top, + right: 0.0, + bottom: 0.0, + child: new MaterialApp( + home: new Column( + children: [ + new Draggable( + data: 1, + child: const Text('Source'), + feedback: const Text('Dragging'), + onDragStarted: () { + ++dragStartedCount; + }, + ), + new DragTarget( + builder: (BuildContext context, List data, List rejects) { + return new Container(height: 100.0, child: const Text('Target')); + }, + onAccept: accepted.add, + ), + ], ), - new DragTarget( - builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); - }, - onAccept: accepted.add - ), - ] - ) - ) - ) - ])); + ), + ), + ], + ), + ); expect(accepted, isEmpty); expect(find.text('Source'), findsOneWidget); diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index f93df040c5..7e2feeca08 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -10,32 +10,35 @@ void main() { testWidgets('Can hit test flex children of stacks', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Container( - color: const Color(0xFF00FF00), - child: new Stack( - children: [ - new Positioned( - top: 10.0, - left: 10.0, - child: new Column( - children: [ - new GestureDetector( - onTap: () { - didReceiveTap = true; - }, - child: new Container( - color: const Color(0xFF0000FF), - width: 100.0, - height: 100.0, - child: const Center( - child: const Text('X', textDirection: TextDirection.ltr), + new Directionality( + textDirection: TextDirection.ltr, + child: new Container( + color: const Color(0xFF00FF00), + child: new Stack( + children: [ + new Positioned( + top: 10.0, + left: 10.0, + child: new Column( + children: [ + new GestureDetector( + onTap: () { + didReceiveTap = true; + }, + child: new Container( + color: const Color(0xFF0000FF), + width: 100.0, + height: 100.0, + child: const Center( + child: const Text('X', textDirection: TextDirection.ltr), + ), ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), ); diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index 76ccd94b87..e464d2f502 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -47,6 +47,7 @@ void main() { testWidgets('GlobalKey duplication 1 - double appearance', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container( key: const ValueKey(1), @@ -65,6 +66,7 @@ void main() { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container( key: const ValueKey(1), @@ -79,6 +81,7 @@ void main() { )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container( key: const ValueKey(1), @@ -97,11 +100,13 @@ void main() { testWidgets('GlobalKey duplication 3 - splitting and changing type', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new SizedBox(key: key), new Placeholder(key: key), @@ -113,11 +118,13 @@ void main() { testWidgets('GlobalKey duplication 4 - splitting and half changing type', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), new Placeholder(key: key), @@ -129,11 +136,13 @@ void main() { testWidgets('GlobalKey duplication 5 - splitting and half changing type', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Placeholder(key: key), new Container(key: key), @@ -145,11 +154,13 @@ void main() { testWidgets('GlobalKey duplication 6 - splitting and not changing type', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), new Container(key: key), @@ -161,12 +172,14 @@ void main() { testWidgets('GlobalKey duplication 7 - appearing later', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(1), child: new Container(key: key)), new Container(key: const ValueKey(2)), ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(1), child: new Container(key: key)), new Container(key: const ValueKey(2), child: new Container(key: key)), @@ -178,12 +191,14 @@ void main() { testWidgets('GlobalKey duplication 8 - appearing earlier', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(1)), new Container(key: const ValueKey(2), child: new Container(key: key)), ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(1), child: new Container(key: key)), new Container(key: const ValueKey(2), child: new Container(key: key)), @@ -195,6 +210,7 @@ void main() { testWidgets('GlobalKey duplication 9 - moving and appearing later', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0), child: new Container(key: key)), new Container(key: const ValueKey(1)), @@ -202,6 +218,7 @@ void main() { ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0)), new Container(key: const ValueKey(1), child: new Container(key: key)), @@ -214,6 +231,7 @@ void main() { testWidgets('GlobalKey duplication 10 - moving and appearing earlier', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(1)), new Container(key: const ValueKey(2)), @@ -221,6 +239,7 @@ void main() { ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(1), child: new Container(key: key)), new Container(key: const ValueKey(2), child: new Container(key: key)), @@ -233,6 +252,7 @@ void main() { testWidgets('GlobalKey duplication 11 - double sibling appearance', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), new Container(key: key), @@ -246,6 +266,7 @@ void main() { final Key key2 = new GlobalKey(debugLabel: 'problematic'); // intentionally the same label final Key key3 = new GlobalKey(debugLabel: 'also problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key1), new Container(key: key1), @@ -284,6 +305,7 @@ void main() { final Key key2 = new GlobalKey(debugLabel: 'problematic'); // intentionally the same label final Key key3 = new GlobalKey(debugLabel: 'also problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key1), new Container(key: key2), @@ -291,6 +313,7 @@ void main() { ]), ); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key1), new Container(key: key1), @@ -327,6 +350,7 @@ void main() { testWidgets('GlobalKey duplication 14 - moving during build - before', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), new Container(key: const ValueKey(0)), @@ -334,6 +358,7 @@ void main() { ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0)), new Container(key: const ValueKey(1), child: new Container(key: key)), @@ -344,6 +369,7 @@ void main() { testWidgets('GlobalKey duplication 15 - duplicating during build - before', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), new Container(key: const ValueKey(0)), @@ -351,6 +377,7 @@ void main() { ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: key), new Container(key: const ValueKey(0)), @@ -363,6 +390,7 @@ void main() { testWidgets('GlobalKey duplication 16 - moving during build - after', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0)), new Container(key: const ValueKey(1)), @@ -370,6 +398,7 @@ void main() { ], )); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0)), new Container(key: const ValueKey(1), child: new Container(key: key)), @@ -380,6 +409,7 @@ void main() { testWidgets('GlobalKey duplication 17 - duplicating during build - after', (WidgetTester tester) async { final Key key = new GlobalKey(debugLabel: 'problematic'); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0)), new Container(key: const ValueKey(1)), @@ -393,6 +423,7 @@ void main() { count += 1; }; await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(key: const ValueKey(0)), new Container(key: const ValueKey(1), child: new Container(key: key)), diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index 9c94af5bba..f4644c8771 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -25,7 +25,7 @@ void main() { }, child: new Container( color: const Color(0xFF00FF00), - ) + ), ); await tester.pumpWidget(widget); @@ -70,7 +70,7 @@ void main() { onHorizontalDragEnd: (DragEndDetails details) { fail('gesture should not match'); }, child: new Container( color: const Color(0xFF00FF00), - ) + ), ); await tester.pumpWidget(widget); @@ -106,8 +106,8 @@ void main() { }, child: new Container( color: const Color(0xFF00FF00), - ) - ) + ), + ), ); expect(didStartPan, isFalse); @@ -128,30 +128,33 @@ void main() { Future pumpWidgetTree(HitTestBehavior behavior) { return tester.pumpWidget( - new Stack( - children: [ - new Listener( - onPointerDown: (_) { - didReceivePointerDown = true; - }, - child: new Container( + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Listener( + onPointerDown: (_) { + didReceivePointerDown = true; + }, + child: new Container( + width: 100.0, + height: 100.0, + color: const Color(0xFF00FF00), + ), + ), + new Container( width: 100.0, height: 100.0, - color: const Color(0xFF00FF00), - ) - ), - new Container( - width: 100.0, - height: 100.0, - child: new GestureDetector( - onTap: () { - didTap = true; - }, - behavior: behavior - ) - ) - ] - ) + child: new GestureDetector( + onTap: () { + didTap = true; + }, + behavior: behavior, + ), + ), + ], + ), + ), ); } @@ -193,8 +196,8 @@ void main() { onTap: () { didTap = true; }, - ) - ) + ), + ), ); expect(didTap, isFalse); await tester.tapAt(const Offset(10.0, 10.0)); @@ -210,8 +213,8 @@ void main() { didTap = true; }, child: new Container(), - ) - ) + ), + ), ); expect(didTap, isFalse); await tester.tapAt(const Offset(10.0, 10.0)); @@ -222,24 +225,24 @@ void main() { final GestureTapCallback inputCallback = () {}; await tester.pumpWidget( - new Center( - child: new GestureDetector( - onTap: inputCallback, - child: new Container(), - ) - ) + new Center( + child: new GestureDetector( + onTap: inputCallback, + child: new Container(), + ), + ), ); final RenderSemanticsGestureHandler renderObj1 = tester.renderObject(find.byType(GestureDetector)); final GestureTapCallback actualCallback1 = renderObj1.onTap; await tester.pumpWidget( - new Center( - child: new GestureDetector( - onTap: inputCallback, - child: new Container(), - ) - ) + new Center( + child: new GestureDetector( + onTap: inputCallback, + child: new Container(), + ), + ), ); final RenderSemanticsGestureHandler renderObj2 = tester.renderObject(find.byType(GestureDetector)); diff --git a/packages/flutter/test/widgets/modal_barrier_test.dart b/packages/flutter/test/widgets/modal_barrier_test.dart index b2d628fcb9..c58702fc89 100644 --- a/packages/flutter/test/widgets/modal_barrier_test.dart +++ b/packages/flutter/test/widgets/modal_barrier_test.dart @@ -30,6 +30,7 @@ void main() { testWidgets('ModalBarrier prevents interactions with widgets behind it', (WidgetTester tester) async { final Widget subject = new Stack( + textDirection: TextDirection.ltr, children: [ tapTarget, const ModalBarrier(dismissible: false), @@ -45,6 +46,7 @@ void main() { testWidgets('ModalBarrier does not prevent interactions with widgets in front of it', (WidgetTester tester) async { final Widget subject = new Stack( + textDirection: TextDirection.ltr, children: [ const ModalBarrier(dismissible: false), tapTarget, diff --git a/packages/flutter/test/widgets/multichild_test.dart b/packages/flutter/test/widgets/multichild_test.dart index a9a60ebd61..343398b559 100644 --- a/packages/flutter/test/widgets/multichild_test.dart +++ b/packages/flutter/test/widgets/multichild_test.dart @@ -36,75 +36,81 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new DecoratedBox(decoration: kBoxDecorationB), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB), new DecoratedBox(decoration: kBoxDecorationC), new DecoratedBox(key: const Key('a'), decoration: kBoxDecorationA), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationB, kBoxDecorationC, kBoxDecorationA]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(key: const Key('a'), decoration: kBoxDecorationA), new DecoratedBox(decoration: kBoxDecorationC), new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationC, kBoxDecorationB]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationC]); await tester.pumpWidget( - new Stack() + new Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -115,116 +121,123 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new DecoratedBox(decoration: kBoxDecorationB), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new Container( child: new DecoratedBox(decoration: kBoxDecorationB) ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new Container( child: new Container( - child: new DecoratedBox(decoration: kBoxDecorationB) - ) + child: new DecoratedBox(decoration: kBoxDecorationB), + ), ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Container( child: new Container( - child: new DecoratedBox(decoration: kBoxDecorationB) - ) + child: new DecoratedBox(decoration: kBoxDecorationB), + ), ), new Container( - child: new DecoratedBox(decoration: kBoxDecorationA) + child: new DecoratedBox(decoration: kBoxDecorationA), ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Container( - child: new DecoratedBox(decoration: kBoxDecorationB) + child: new DecoratedBox(decoration: kBoxDecorationB), ), new Container( - child: new DecoratedBox(decoration: kBoxDecorationA) + child: new DecoratedBox(decoration: kBoxDecorationA), ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Container( key: const Key('b'), - child: new DecoratedBox(decoration: kBoxDecorationB) + child: new DecoratedBox(decoration: kBoxDecorationB), ), new Container( key: const Key('a'), - child: new DecoratedBox(decoration: kBoxDecorationA) + child: new DecoratedBox(decoration: kBoxDecorationA), ), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationB, kBoxDecorationA]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Container( key: const Key('a'), - child: new DecoratedBox(decoration: kBoxDecorationA) + child: new DecoratedBox(decoration: kBoxDecorationA), ), new Container( key: const Key('b'), - child: new DecoratedBox(decoration: kBoxDecorationB) + child: new DecoratedBox(decoration: kBoxDecorationB), ), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB]); await tester.pumpWidget( - new Stack() + new Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -233,25 +246,27 @@ void main() { testWidgets('MultiChildRenderObjectElement with stateful widgets', (WidgetTester tester) async { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new DecoratedBox(decoration: kBoxDecorationB), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationB]); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new FlipWidget( left: new DecoratedBox(decoration: kBoxDecorationA), - right: new DecoratedBox(decoration: kBoxDecorationB) + right: new DecoratedBox(decoration: kBoxDecorationB), ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationA, kBoxDecorationC]); @@ -263,13 +278,14 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new FlipWidget( left: new DecoratedBox(decoration: kBoxDecorationA), - right: new DecoratedBox(decoration: kBoxDecorationB) + right: new DecoratedBox(decoration: kBoxDecorationB), ), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationB]); @@ -281,27 +297,29 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new FlipWidget( key: const Key('flip'), left: new DecoratedBox(decoration: kBoxDecorationA), - right: new DecoratedBox(decoration: kBoxDecorationB) + right: new DecoratedBox(decoration: kBoxDecorationB), ), - ] - ) + ], + ), ); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(key: const Key('c'), decoration: kBoxDecorationC), new FlipWidget( key: const Key('flip'), left: new DecoratedBox(decoration: kBoxDecorationA), - right: new DecoratedBox(decoration: kBoxDecorationB) + right: new DecoratedBox(decoration: kBoxDecorationB), ), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationC, kBoxDecorationA]); @@ -313,15 +331,16 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new FlipWidget( key: const Key('flip'), left: new DecoratedBox(decoration: kBoxDecorationA), - right: new DecoratedBox(decoration: kBoxDecorationB) + right: new DecoratedBox(decoration: kBoxDecorationB), ), new DecoratedBox(key: const Key('c'), decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [kBoxDecorationB, kBoxDecorationC]); diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index f7619beb7a..c7e701320b 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -10,20 +10,25 @@ void main() { (WidgetTester tester) async { final GlobalKey overlayKey = new GlobalKey(); bool didBuild = false; - await tester.pumpWidget(new Overlay( - key: overlayKey, - initialEntries: [ - new OverlayEntry( - builder: (BuildContext context) { - didBuild = true; - final Overlay overlay = context.ancestorWidgetOfExactType(Overlay); - expect(overlay, isNotNull); - expect(overlay.key, equals(overlayKey)); - return new Container(); - }, + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Overlay( + key: overlayKey, + initialEntries: [ + new OverlayEntry( + builder: (BuildContext context) { + didBuild = true; + final Overlay overlay = context.ancestorWidgetOfExactType(Overlay); + expect(overlay, isNotNull); + expect(overlay.key, equals(overlayKey)); + return new Container(); + }, + ), + ], ), - ], - )); + ), + ); expect(didBuild, isTrue); final RenderObject theater = overlayKey.currentContext.findRenderObject(); @@ -32,25 +37,29 @@ void main() { theater.toStringDeep(), equalsIgnoringHashCodes( '_RenderTheatre#00000\n' - ' │ creator: _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' + ' │ creator: _Theatre ← Overlay-[GlobalKey#00000] ← Directionality ←\n' + ' │ [root]\n' ' │ parentData: \n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ size: Size(800.0, 600.0)\n' ' │\n' ' ├─onstage: RenderStack#00000\n' - ' ╎ │ creator: Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' + ' ╎ │ creator: Stack ← _Theatre ← Overlay-[GlobalKey#00000] ←\n' + ' ╎ │ Directionality ← [root]\n' ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n' ' ╎ │ size)\n' ' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' ╎ │ size: Size(800.0, 600.0)\n' - ' ╎ │ alignment: FractionalOffset.topLeft\n' + ' ╎ │ alignment: FractionalOffsetDirectional.topStart\n' + ' ╎ │ textDirection: ltr\n' ' ╎ │ fit: expand\n' ' ╎ │ overflow: clip\n' ' ╎ │\n' ' ╎ └─child 1: RenderLimitedBox#00000\n' ' ╎ │ creator: LimitedBox ← Container ←\n' ' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' ╎ │ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' + ' ╎ │ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← Directionality ←\n' + ' ╎ │ [root]\n' ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n' ' ╎ │ size)\n' ' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n' @@ -61,118 +70,133 @@ void main() { ' ╎ └─child: RenderConstrainedBox#00000\n' ' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n' ' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' ╎ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' + ' ╎ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← Directionality ←\n' + ' ╎ [root]\n' ' ╎ parentData: (can use size)\n' ' ╎ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' ╎ size: Size(800.0, 600.0)\n' ' ╎ additionalConstraints: BoxConstraints(biggest)\n' ' ╎\n' - ' └╌no offstage children\n', + ' └╌no offstage children\n' ), ); }); testWidgets('Offstage overlay', (WidgetTester tester) async { final GlobalKey overlayKey = new GlobalKey(); - await tester.pumpWidget(new Overlay( - key: overlayKey, - initialEntries: [ - new OverlayEntry( - opaque: true, - maintainState: true, - builder: (BuildContext context) => new Container(), + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Overlay( + key: overlayKey, + initialEntries: [ + new OverlayEntry( + opaque: true, + maintainState: true, + builder: (BuildContext context) => new Container(), + ), + new OverlayEntry( + opaque: true, + maintainState: true, + builder: (BuildContext context) => new Container(), + ), + new OverlayEntry( + opaque: true, + maintainState: true, + builder: (BuildContext context) => new Container(), + ), + ], ), - new OverlayEntry( - opaque: true, - maintainState: true, - builder: (BuildContext context) => new Container(), - ), - new OverlayEntry( - opaque: true, - maintainState: true, - builder: (BuildContext context) => new Container(), - ), - ], - )); + ), + ); final RenderObject theater = overlayKey.currentContext.findRenderObject(); expect(theater, hasAGoodToStringDeep); expect( theater.toStringDeep(), equalsIgnoringHashCodes( - '_RenderTheatre#00000\n' - ' │ creator: _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' │ parentData: \n' - ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' - ' │ size: Size(800.0, 600.0)\n' - ' │\n' - ' ├─onstage: RenderStack#00000\n' - ' ╎ │ creator: Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n' - ' ╎ │ size)\n' - ' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n' - ' ╎ │ size: Size(800.0, 600.0)\n' - ' ╎ │ alignment: FractionalOffset.topLeft\n' - ' ╎ │ fit: expand\n' - ' ╎ │ overflow: clip\n' - ' ╎ │\n' - ' ╎ └─child 1: RenderLimitedBox#00000\n' - ' ╎ │ creator: LimitedBox ← Container ←\n' - ' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' ╎ │ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n' - ' ╎ │ size)\n' - ' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n' - ' ╎ │ size: Size(800.0, 600.0)\n' - ' ╎ │ maxWidth: 0.0\n' - ' ╎ │ maxHeight: 0.0\n' - ' ╎ │\n' - ' ╎ └─child: RenderConstrainedBox#00000\n' - ' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n' - ' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' ╎ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' ╎ parentData: (can use size)\n' - ' ╎ constraints: BoxConstraints(w=800.0, h=600.0)\n' - ' ╎ size: Size(800.0, 600.0)\n' - ' ╎ additionalConstraints: BoxConstraints(biggest)\n' - ' ╎\n' - ' ╎╌offstage 1: RenderLimitedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' - ' ╎ │ creator: LimitedBox ← Container ←\n' - ' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' ╎ │ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0)\n' - ' ╎ │ constraints: MISSING\n' - ' ╎ │ size: MISSING\n' - ' ╎ │ maxWidth: 0.0\n' - ' ╎ │ maxHeight: 0.0\n' - ' ╎ │\n' - ' ╎ └─child: RenderConstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' - ' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n' - ' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' ╎ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' ╎ parentData: \n' - ' ╎ constraints: MISSING\n' - ' ╎ size: MISSING\n' - ' ╎ additionalConstraints: BoxConstraints(biggest)\n' - ' ╎\n' - ' └╌offstage 2: RenderLimitedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' - ' │ creator: LimitedBox ← Container ←\n' - ' │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' │ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' │ parentData: not positioned; offset=Offset(0.0, 0.0)\n' - ' │ constraints: MISSING\n' - ' │ size: MISSING\n' - ' │ maxWidth: 0.0\n' - ' │ maxHeight: 0.0\n' - ' │\n' - ' └─child: RenderConstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' - ' creator: ConstrainedBox ← LimitedBox ← Container ←\n' - ' _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' - ' TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ← [root]\n' - ' parentData: \n' - ' constraints: MISSING\n' - ' size: MISSING\n' - ' additionalConstraints: BoxConstraints(biggest)\n' + '_RenderTheatre#00000\n' + ' │ creator: _Theatre ← Overlay-[GlobalKey#00000] ← Directionality ←\n' + ' │ [root]\n' + ' │ parentData: \n' + ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' + ' │ size: Size(800.0, 600.0)\n' + ' │\n' + ' ├─onstage: RenderStack#00000\n' + ' ╎ │ creator: Stack ← _Theatre ← Overlay-[GlobalKey#00000] ←\n' + ' ╎ │ Directionality ← [root]\n' + ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n' + ' ╎ │ size)\n' + ' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n' + ' ╎ │ size: Size(800.0, 600.0)\n' + ' ╎ │ alignment: FractionalOffsetDirectional.topStart\n' + ' ╎ │ textDirection: ltr\n' + ' ╎ │ fit: expand\n' + ' ╎ │ overflow: clip\n' + ' ╎ │\n' + ' ╎ └─child 1: RenderLimitedBox#00000\n' + ' ╎ │ creator: LimitedBox ← Container ←\n' + ' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' + ' ╎ │ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← Directionality ←\n' + ' ╎ │ [root]\n' + ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n' + ' ╎ │ size)\n' + ' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n' + ' ╎ │ size: Size(800.0, 600.0)\n' + ' ╎ │ maxWidth: 0.0\n' + ' ╎ │ maxHeight: 0.0\n' + ' ╎ │\n' + ' ╎ └─child: RenderConstrainedBox#00000\n' + ' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n' + ' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' + ' ╎ Stack ← _Theatre ← Overlay-[GlobalKey#00000] ← Directionality ←\n' + ' ╎ [root]\n' + ' ╎ parentData: (can use size)\n' + ' ╎ constraints: BoxConstraints(w=800.0, h=600.0)\n' + ' ╎ size: Size(800.0, 600.0)\n' + ' ╎ additionalConstraints: BoxConstraints(biggest)\n' + ' ╎\n' + ' ╎╌offstage 1: RenderLimitedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' + ' ╎ │ creator: LimitedBox ← Container ←\n' + ' ╎ │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' + ' ╎ │ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ←\n' + ' ╎ │ Directionality ← [root]\n' + ' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0)\n' + ' ╎ │ constraints: MISSING\n' + ' ╎ │ size: MISSING\n' + ' ╎ │ maxWidth: 0.0\n' + ' ╎ │ maxHeight: 0.0\n' + ' ╎ │\n' + ' ╎ └─child: RenderConstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' + ' ╎ creator: ConstrainedBox ← LimitedBox ← Container ←\n' + ' ╎ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' + ' ╎ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ←\n' + ' ╎ Directionality ← [root]\n' + ' ╎ parentData: \n' + ' ╎ constraints: MISSING\n' + ' ╎ size: MISSING\n' + ' ╎ additionalConstraints: BoxConstraints(biggest)\n' + ' ╎\n' + ' └╌offstage 2: RenderLimitedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' + ' │ creator: LimitedBox ← Container ←\n' + ' │ _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' + ' │ TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ←\n' + ' │ Directionality ← [root]\n' + ' │ parentData: not positioned; offset=Offset(0.0, 0.0)\n' + ' │ constraints: MISSING\n' + ' │ size: MISSING\n' + ' │ maxWidth: 0.0\n' + ' │ maxHeight: 0.0\n' + ' │\n' + ' └─child: RenderConstrainedBox#00000 NEEDS-LAYOUT NEEDS-PAINT\n' + ' creator: ConstrainedBox ← LimitedBox ← Container ←\n' + ' _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#00000] ←\n' + ' TickerMode ← _Theatre ← Overlay-[GlobalKey#00000] ←\n' + ' Directionality ← [root]\n' + ' parentData: \n' + ' constraints: MISSING\n' + ' size: MISSING\n' + ' additionalConstraints: BoxConstraints(biggest)\n' ), ); }); diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index 1175ff9aeb..c28fe85deb 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_test.dart @@ -52,16 +52,17 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new DecoratedBox(decoration: kBoxDecorationA), new Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox(decoration: kBoxDecorationB) + child: new DecoratedBox(decoration: kBoxDecorationB), ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [ @@ -72,20 +73,21 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( bottom: 5.0, right: 7.0, - child: new DecoratedBox(decoration: kBoxDecorationA) + child: new DecoratedBox(decoration: kBoxDecorationA), ), new Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox(decoration: kBoxDecorationB) + child: new DecoratedBox(decoration: kBoxDecorationB), ), new DecoratedBox(decoration: kBoxDecorationC), - ] - ) + ], + ), ); checkTree(tester, [ @@ -100,20 +102,21 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( bottom: 5.0, right: 7.0, - child: kDecoratedBoxA + child: kDecoratedBoxA, ), new Positioned( top: 10.0, left: 10.0, - child: kDecoratedBoxB + child: kDecoratedBoxB, ), kDecoratedBoxC, - ] - ) + ], + ), ); checkTree(tester, [ @@ -124,20 +127,21 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( bottom: 6.0, right: 8.0, - child: kDecoratedBoxA + child: kDecoratedBoxA, ), new Positioned( left: 10.0, right: 10.0, - child: kDecoratedBoxB + child: kDecoratedBoxB, ), kDecoratedBoxC, - ] - ) + ], + ), ); checkTree(tester, [ @@ -148,16 +152,17 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ kDecoratedBoxA, new Positioned( left: 11.0, right: 12.0, - child: new Container(child: kDecoratedBoxB) + child: new Container(child: kDecoratedBoxB), ), kDecoratedBoxC, - ] - ) + ], + ), ); checkTree(tester, [ @@ -168,20 +173,21 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ kDecoratedBoxA, new Positioned( right: 10.0, - child: new Container(child: kDecoratedBoxB) + child: new Container(child: kDecoratedBoxB), ), new Container( child: new Positioned( top: 8.0, - child: kDecoratedBoxC - ) - ) - ] - ) + child: kDecoratedBoxC, + ), + ), + ], + ), ); checkTree(tester, [ @@ -192,13 +198,14 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( right: 10.0, - child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB) + child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB), ), - ] - ) + ], + ), ); checkTree(tester, [ @@ -214,13 +221,14 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( top: 7.0, - child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB) + child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB), ), - ] - ) + ], + ), ); checkTree(tester, [ @@ -235,7 +243,7 @@ void main() { ]); await tester.pumpWidget( - new Stack() + new Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -244,6 +252,7 @@ void main() { testWidgets('ParentDataWidget conflicting data', (WidgetTester tester) async { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( top: 5.0, @@ -251,15 +260,15 @@ void main() { child: new Positioned( top: 6.0, left: 7.0, - child: new DecoratedBox(decoration: kBoxDecorationB) - ) - ) - ] - ) + child: new DecoratedBox(decoration: kBoxDecorationB), + ), + ), + ], + ), ); expect(tester.takeException(), isFlutterError); - await tester.pumpWidget(new Stack()); + await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr)); checkTree(tester, []); @@ -270,16 +279,16 @@ void main() { new Positioned( top: 6.0, left: 7.0, - child: new DecoratedBox(decoration: kBoxDecorationB) - ) - ] - ) - ) + child: new DecoratedBox(decoration: kBoxDecorationB), + ), + ], + ), + ), ); expect(tester.takeException(), isFlutterError); await tester.pumpWidget( - new Stack() + new Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -290,14 +299,15 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox(key: key, decoration: kBoxDecorationA) - ) - ] - ) + child: new DecoratedBox(key: key, decoration: kBoxDecorationA), + ), + ], + ), ); checkTree(tester, [ @@ -306,17 +316,18 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( top: 10.0, left: 10.0, child: new DecoratedBox( decoration: kBoxDecorationB, - child: new DecoratedBox(key: key, decoration: kBoxDecorationA) - ) - ) - ] - ) + child: new DecoratedBox(key: key, decoration: kBoxDecorationA), + ), + ), + ], + ), ); checkTree(tester, [ @@ -325,14 +336,15 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox(key: key, decoration: kBoxDecorationA) - ) - ] - ) + child: new DecoratedBox(key: key, decoration: kBoxDecorationA), + ), + ], + ), ); checkTree(tester, [ @@ -344,6 +356,7 @@ void main() { await tester.pumpWidget(new Row( children: [ new Stack( + textDirection: TextDirection.ltr, children: [ new Expanded( child: new Container() diff --git a/packages/flutter/test/widgets/placeholder_test.dart b/packages/flutter/test/widgets/placeholder_test.dart index 1b4d3f1db5..a286af7463 100644 --- a/packages/flutter/test/widgets/placeholder_test.dart +++ b/packages/flutter/test/widgets/placeholder_test.dart @@ -13,11 +13,11 @@ void main() { expect(tester.renderObject(find.byType(Placeholder)).size, const Size(800.0, 600.0)); await tester.pumpWidget(const Center(child: const Placeholder())); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(800.0, 600.0)); - await tester.pumpWidget(new Stack(children: [const Positioned(top: 0.0, bottom: 0.0, child: const Placeholder())])); + await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: [const Positioned(top: 0.0, bottom: 0.0, child: const Placeholder())])); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(400.0, 600.0)); - await tester.pumpWidget(new Stack(children: [const Positioned(left: 0.0, right: 0.0, child: const Placeholder())])); + await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: [const Positioned(left: 0.0, right: 0.0, child: const Placeholder())])); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(800.0, 400.0)); - await tester.pumpWidget(new Stack(children: [const Positioned(top: 0.0, child: const Placeholder(fallbackWidth: 200.0, fallbackHeight: 300.0))])); + await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: [const Positioned(top: 0.0, child: const Placeholder(fallbackWidth: 200.0, fallbackHeight: 300.0))])); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(200.0, 300.0)); }); diff --git a/packages/flutter/test/widgets/positioned_test.dart b/packages/flutter/test/widgets/positioned_test.dart index 7dc912258e..454259ac8e 100644 --- a/packages/flutter/test/widgets/positioned_test.dart +++ b/packages/flutter/test/widgets/positioned_test.dart @@ -60,11 +60,11 @@ void main() { final RelativeRectTween rect = new RelativeRectTween( begin: new RelativeRect.fromRect( new Rect.fromLTRB(10.0, 20.0, 20.0, 30.0), - new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0) + new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0), ), end: new RelativeRect.fromRect( new Rect.fromLTRB(80.0, 90.0, 90.0, 100.0), - new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0) + new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0), ) ); final AnimationController controller = new AnimationController( @@ -83,22 +83,25 @@ void main() { } await tester.pumpWidget( - new Center( - child: new Container( - height: 100.0, - width: 100.0, - child: new Stack( - children: [ - new PositionedTransition( - rect: rect.animate(controller), - child: new Container( - key: key - ) - ) - ] - ) - ) - ) + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new Container( + height: 100.0, + width: 100.0, + child: new Stack( + children: [ + new PositionedTransition( + rect: rect.animate(controller), + child: new Container( + key: key, + ), + ), + ], + ), + ), + ), + ), ); // t=0 recordMetrics(); final Completer completer = new Completer(); diff --git a/packages/flutter/test/widgets/reparent_state_harder_test.dart b/packages/flutter/test/widgets/reparent_state_harder_test.dart index 0c786b5ac1..b279281443 100644 --- a/packages/flutter/test/widgets/reparent_state_harder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_harder_test.dart @@ -38,7 +38,8 @@ class OrderSwitcherState extends State { children.add(widget.a); } return new Stack( - children: children + textDirection: TextDirection.ltr, + children: children, ); } } diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index e02565e487..706abf40b7 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -56,6 +56,7 @@ void main() { final StateMarker grandchild = const StateMarker(); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Container( child: new StateMarker(key: left) @@ -82,6 +83,7 @@ void main() { final StateMarker newGrandchild = const StateMarker(); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Container( child: new StateMarker( @@ -129,6 +131,7 @@ void main() { final StateMarker grandchild = const StateMarker(); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new StateMarker(key: left), new StateMarker( @@ -151,6 +154,7 @@ void main() { final StateMarker newGrandchild = const StateMarker(); await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new StateMarker( key: right, @@ -224,6 +228,7 @@ void main() { final GlobalKey key = new GlobalKey(); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new StateMarker(key: key), new Container(width: 100.0, height: 100.0), @@ -234,6 +239,7 @@ void main() { keyState.marker = "marked"; await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(width: 100.0, height: 100.0), new StateMarker(key: key), @@ -244,6 +250,7 @@ void main() { expect(keyState.marker, equals("marked")); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new StateMarker(key: key), new Container(width: 100.0, height: 100.0), @@ -258,6 +265,7 @@ void main() { final GlobalKey key = new GlobalKey(); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(width: 100.0, height: 100.0), new StateMarker(key: key), @@ -269,6 +277,7 @@ void main() { keyState.marker = "marked"; await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(width: 100.0, height: 100.0, child: new StateMarker(key: key)), new Container(width: 100.0, height: 100.0), @@ -279,6 +288,7 @@ void main() { expect(keyState.marker, equals("marked")); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(width: 100.0, height: 100.0), new StateMarker(key: key), @@ -290,6 +300,7 @@ void main() { expect(keyState.marker, equals("marked")); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(width: 100.0, height: 100.0), new Container(width: 100.0, height: 100.0, child: new StateMarker(key: key)), @@ -300,6 +311,7 @@ void main() { expect(keyState.marker, equals("marked")); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Container(width: 100.0, height: 100.0), new StateMarker(key: key), diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index a9958caf76..70dbf73046 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -109,10 +109,15 @@ void main() { testWidgets('Route management - push, replace, pop', (WidgetTester tester) async { final GlobalKey navigatorKey = new GlobalKey(); - await tester.pumpWidget(new Navigator( - key: navigatorKey, - onGenerateRoute: (_) => new TestRoute('initial') - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Navigator( + key: navigatorKey, + onGenerateRoute: (_) => new TestRoute('initial'), + ), + ), + ); final NavigatorState host = navigatorKey.currentState; await runNavigatorTest( tester, @@ -187,10 +192,15 @@ void main() { testWidgets('Route management - push, remove, pop', (WidgetTester tester) async { final GlobalKey navigatorKey = new GlobalKey(); - await tester.pumpWidget(new Navigator( - key: navigatorKey, - onGenerateRoute: (_) => new TestRoute('first') - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Navigator( + key: navigatorKey, + onGenerateRoute: (_) => new TestRoute('first') + ), + ), + ); final NavigatorState host = navigatorKey.currentState; await runNavigatorTest( tester, @@ -293,10 +303,15 @@ void main() { testWidgets('Route management - push, replace, popUntil', (WidgetTester tester) async { final GlobalKey navigatorKey = new GlobalKey(); - await tester.pumpWidget(new Navigator( - key: navigatorKey, - onGenerateRoute: (_) => new TestRoute('A') - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Navigator( + key: navigatorKey, + onGenerateRoute: (_) => new TestRoute('A') + ), + ), + ); final NavigatorState host = navigatorKey.currentState; await runNavigatorTest( tester, @@ -370,10 +385,15 @@ void main() { onRemove: () { routeA.log('onRemove 1'); } )); final GlobalKey navigatorKey = new GlobalKey(); - await tester.pumpWidget(new Navigator( - key: navigatorKey, - onGenerateRoute: (_) => routeA - )); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Navigator( + key: navigatorKey, + onGenerateRoute: (_) => routeA + ), + ), + ); final NavigatorState host = navigatorKey.currentState; await runNavigatorTest( tester, diff --git a/packages/flutter/test/widgets/semantics_5_test.dart b/packages/flutter/test/widgets/semantics_5_test.dart index 7ff598f93b..3284e78776 100644 --- a/packages/flutter/test/widgets/semantics_5_test.dart +++ b/packages/flutter/test/widgets/semantics_5_test.dart @@ -14,6 +14,7 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, fit: StackFit.expand, children: [ const Semantics( diff --git a/packages/flutter/test/widgets/semantics_8_test.dart b/packages/flutter/test/widgets/semantics_8_test.dart index f7fa9205d2..58f1c8107a 100644 --- a/packages/flutter/test/widgets/semantics_8_test.dart +++ b/packages/flutter/test/widgets/semantics_8_test.dart @@ -21,6 +21,7 @@ void main() { child: new Semantics( container: true, child: new Stack( + textDirection: TextDirection.ltr, children: [ const Semantics( checked: true, @@ -52,6 +53,7 @@ void main() { child: new Semantics( container: true, child: new Stack( + textDirection: TextDirection.ltr, children: [ const Semantics( label: 'label', diff --git a/packages/flutter/test/widgets/semantics_9_test.dart b/packages/flutter/test/widgets/semantics_9_test.dart index cbe0db7cf7..4480f2ffdf 100644 --- a/packages/flutter/test/widgets/semantics_9_test.dart +++ b/packages/flutter/test/widgets/semantics_9_test.dart @@ -15,6 +15,7 @@ void main() { final SemanticsTester semantics = new SemanticsTester(tester); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Semantics( label: 'layer#1', @@ -33,6 +34,7 @@ void main() { expect(semantics, isNot(includesNodeWith(label: 'layer#1'))); await tester.pumpWidget(new Stack( + textDirection: TextDirection.ltr, children: [ new Semantics( label: 'layer#1', diff --git a/packages/flutter/test/widgets/semantics_debugger_test.dart b/packages/flutter/test/widgets/semantics_debugger_test.dart index 2ee479837e..9be6e32b81 100644 --- a/packages/flutter/test/widgets/semantics_debugger_test.dart +++ b/packages/flutter/test/widgets/semantics_debugger_test.dart @@ -12,22 +12,8 @@ void main() { // This is a smoketest to verify that adding a debugger doesn't crash. await tester.pumpWidget( - new Stack( - children: [ - const Semantics(), - const Semantics( - container: true, - ), - const Semantics( - label: 'label', - textDirection: TextDirection.ltr, - ), - ], - ), - ); - - await tester.pumpWidget( - new SemanticsDebugger( + new Directionality( + textDirection: TextDirection.ltr, child: new Stack( children: [ const Semantics(), @@ -43,6 +29,26 @@ void main() { ), ); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new SemanticsDebugger( + child: new Stack( + children: [ + const Semantics(), + const Semantics( + container: true, + ), + const Semantics( + label: 'label', + textDirection: TextDirection.ltr, + ), + ], + ), + ), + ), + ); + expect(true, isTrue); // expect that we reach here without crashing }); @@ -51,71 +57,80 @@ void main() { final GlobalKey key = new GlobalKey(); await tester.pumpWidget( - new SemanticsDebugger( - child: new Stack( - children: [ - const Semantics(label: 'label1', textDirection: TextDirection.ltr), - new Positioned( - key: key, - left: 0.0, - top: 0.0, - width: 100.0, - height: 100.0, - child: const Semantics(label: 'label2', textDirection: TextDirection.ltr), - ), - ], - ), - ), - ); - - await tester.pumpWidget( - new SemanticsDebugger( - child: new Stack( - children: [ - const Semantics(label: 'label1', textDirection: TextDirection.ltr), - new Semantics( - container: true, - child: new Stack( - children: [ - new Positioned( - key: key, - left: 0.0, - top: 0.0, - width: 100.0, - height: 100.0, - child: const Semantics(label: 'label2', textDirection: TextDirection.ltr), - ), - const Semantics(label: 'label3', textDirection: TextDirection.ltr), - ], + new Directionality( + textDirection: TextDirection.ltr, + child: new SemanticsDebugger( + child: new Stack( + children: [ + const Semantics(label: 'label1', textDirection: TextDirection.ltr), + new Positioned( + key: key, + left: 0.0, + top: 0.0, + width: 100.0, + height: 100.0, + child: const Semantics(label: 'label2', textDirection: TextDirection.ltr), ), - ), - ], + ], + ), ), ), ); await tester.pumpWidget( - new SemanticsDebugger( - child: new Stack( - children: [ - const Semantics(label: 'label1', textDirection: TextDirection.ltr), - new Semantics( - container: true, - child: new Stack( - children: [ - new Positioned( + new Directionality( + textDirection: TextDirection.ltr, + child: new SemanticsDebugger( + child: new Stack( + children: [ + const Semantics(label: 'label1', textDirection: TextDirection.ltr), + new Semantics( + container: true, + child: new Stack( + children: [ + new Positioned( key: key, left: 0.0, top: 0.0, width: 100.0, height: 100.0, - child: const Semantics(label: 'label2', textDirection: TextDirection.ltr)), - const Semantics(label: 'label3', textDirection: TextDirection.ltr), - const Semantics(label: 'label4', textDirection: TextDirection.ltr), - ], + child: const Semantics(label: 'label2', textDirection: TextDirection.ltr), + ), + const Semantics(label: 'label3', textDirection: TextDirection.ltr), + ], + ), ), - ), - ], + ], + ), + ), + ), + ); + + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new SemanticsDebugger( + child: new Stack( + children: [ + const Semantics(label: 'label1', textDirection: TextDirection.ltr), + new Semantics( + container: true, + child: new Stack( + children: [ + new Positioned( + key: key, + left: 0.0, + top: 0.0, + width: 100.0, + height: 100.0, + child: const Semantics(label: 'label2', textDirection: TextDirection.ltr)), + const Semantics(label: 'label3', textDirection: TextDirection.ltr), + const Semantics(label: 'label4', textDirection: TextDirection.ltr), + ], + ), + ), + ], + ), ), ), ); @@ -250,13 +265,16 @@ void main() { bool didLongPress = false; await tester.pumpWidget( - new SemanticsDebugger( - child: new GestureDetector( - onLongPress: () { - expect(didLongPress, isFalse); - didLongPress = true; - }, - child: const Text('target', textDirection: TextDirection.ltr), + new Directionality( + textDirection: TextDirection.ltr, + child: new SemanticsDebugger( + child: new GestureDetector( + onLongPress: () { + expect(didLongPress, isFalse); + didLongPress = true; + }, + child: const Text('target', textDirection: TextDirection.ltr), + ), ), ), ); @@ -269,16 +287,19 @@ void main() { double value = 0.75; await tester.pumpWidget( - new SemanticsDebugger( - child: new Directionality( - textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Slider( - value: value, - onChanged: (double newValue) { - value = newValue; - }, + new Directionality( + textDirection: TextDirection.ltr, + child: new SemanticsDebugger( + child: new Directionality( + textDirection: TextDirection.ltr, + child: new Material( + child: new Center( + child: new Slider( + value: value, + onChanged: (double newValue) { + value = newValue; + }, + ), ), ), ), diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index 31c984060c..b2178f78cd 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -19,11 +19,21 @@ class TestPaintingContext implements PaintingContext { void main() { testWidgets('Can construct an empty Stack', (WidgetTester tester) async { - await tester.pumpWidget(new Stack()); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack(), + ), + ); }); testWidgets('Can construct an empty Centered Stack', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new Stack())); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Center(child: new Stack()), + ), + ); }); testWidgets('Can change position data', (WidgetTester tester) async { @@ -31,17 +41,18 @@ void main() { await tester.pumpWidget( new Stack( + alignment: FractionalOffset.topLeft, children: [ new Positioned( left: 10.0, child: new Container( key: key, width: 10.0, - height: 10.0 - ) - ) - ] - ) + height: 10.0, + ), + ), + ], + ), ); Element container; @@ -58,17 +69,18 @@ void main() { await tester.pumpWidget( new Stack( + alignment: FractionalOffset.topLeft, children: [ new Positioned( right: 10.0, child: new Container( key: key, width: 10.0, - height: 10.0 - ) - ) - ] - ) + height: 10.0, + ), + ), + ], + ), ); container = tester.element(find.byKey(key)); @@ -85,7 +97,12 @@ void main() { final Key key = const Key('container'); final Container container = new Container(key: key, width: 10.0, height: 10.0); - await tester.pumpWidget(new Stack(children: [ new Positioned(left: 10.0, child: container) ])); + await tester.pumpWidget( + new Stack( + textDirection: TextDirection.ltr, + children: [ new Positioned(left: 10.0, child: container) ], + ), + ); Element containerElement = tester.element(find.byKey(key)); StackParentData parentData; @@ -97,7 +114,12 @@ void main() { expect(parentData.width, isNull); expect(parentData.height, isNull); - await tester.pumpWidget(new Stack(children: [ container ])); + await tester.pumpWidget( + new Stack( + textDirection: TextDirection.ltr, + children: [ container ], + ), + ); containerElement = tester.element(find.byKey(key)); parentData = containerElement.renderObject.parentData; @@ -109,20 +131,23 @@ void main() { expect(parentData.height, isNull); }); - testWidgets('Can align non-positioned children', (WidgetTester tester) async { + testWidgets('Can align non-positioned children (LTR)', (WidgetTester tester) async { final Key child0Key = const Key('child0'); final Key child1Key = const Key('child1'); await tester.pumpWidget( - new Center( - child: new Stack( - children: [ - new Container(key: child0Key, width: 20.0, height: 20.0), - new Container(key: child1Key, width: 10.0, height: 10.0) - ], - alignment: const FractionalOffset(0.5, 0.5) - ) - ) + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new Stack( + alignment: FractionalOffset.center, + children: [ + new Container(key: child0Key, width: 20.0, height: 20.0), + new Container(key: child1Key, width: 10.0, height: 10.0), + ], + ), + ), + ), ); final Element child0 = tester.element(find.byKey(child0Key)); @@ -132,14 +157,88 @@ void main() { final Element child1 = tester.element(find.byKey(child1Key)); final StackParentData child1RenderObjectParentData = child1.renderObject.parentData; expect(child1RenderObjectParentData.offset, equals(const Offset(5.0, 5.0))); + + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new Stack( + alignment: FractionalOffsetDirectional.bottomEnd, + children: [ + new Container(key: child0Key, width: 20.0, height: 20.0), + new Container(key: child1Key, width: 10.0, height: 10.0), + ], + ), + ), + ), + ); + + expect(child0RenderObjectParentData.offset, equals(const Offset(0.0, 0.0))); + expect(child1RenderObjectParentData.offset, equals(const Offset(10.0, 10.0))); + }); + + testWidgets('Can align non-positioned children (RTL)', (WidgetTester tester) async { + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.rtl, + child: new Center( + child: new Stack( + alignment: FractionalOffset.center, + children: [ + new Container(key: child0Key, width: 20.0, height: 20.0), + new Container(key: child1Key, width: 10.0, height: 10.0), + ], + ), + ), + ), + ); + + final Element child0 = tester.element(find.byKey(child0Key)); + final StackParentData child0RenderObjectParentData = child0.renderObject.parentData; + expect(child0RenderObjectParentData.offset, equals(const Offset(0.0, 0.0))); + + final Element child1 = tester.element(find.byKey(child1Key)); + final StackParentData child1RenderObjectParentData = child1.renderObject.parentData; + expect(child1RenderObjectParentData.offset, equals(const Offset(5.0, 5.0))); + + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.rtl, + child: new Center( + child: new Stack( + alignment: FractionalOffsetDirectional.bottomEnd, + children: [ + new Container(key: child0Key, width: 20.0, height: 20.0), + new Container(key: child1Key, width: 10.0, height: 10.0), + ], + ), + ), + ), + ); + + expect(child0RenderObjectParentData.offset, equals(const Offset(0.0, 0.0))); + expect(child1RenderObjectParentData.offset, equals(const Offset(0.0, 10.0))); }); testWidgets('Can construct an empty IndexedStack', (WidgetTester tester) async { - await tester.pumpWidget(new IndexedStack()); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new IndexedStack(), + ), + ); }); testWidgets('Can construct an empty Centered IndexedStack', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new IndexedStack())); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Center(child: new IndexedStack()), + ), + ); }); testWidgets('Can construct an IndexedStack', (WidgetTester tester) async { @@ -153,10 +252,16 @@ void main() { child: new Text('$i', textDirection: TextDirection.ltr), painter: new TestCallbackPainter( onPaint: () { itemsPainted.add(i); } - ) + ), ); }); - return new Center(child: new IndexedStack(children: items, index: index)); + return new Center( + child: new IndexedStack( + alignment: FractionalOffset.topLeft, + children: items, + index: index, + ), + ); } await tester.pumpWidget(buildFrame(0)); @@ -182,7 +287,14 @@ void main() { final List items = new List.generate(itemCount, (int i) { return new GestureDetector(child: new Text('$i', textDirection: TextDirection.ltr), onTap: () { itemsTapped.add(i); }); }); - return new Center(child: new IndexedStack(children: items, key: key, index: index)); + return new Center( + child: new IndexedStack( + alignment: FractionalOffset.topLeft, + children: items, + key: key, + index: index, + ), + ); } await tester.pumpWidget(buildFrame(0)); @@ -205,15 +317,16 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( left: 10.0, width: 11.0, height: 12.0, - child: new DecoratedBox(key: key, decoration: kBoxDecoration) - ) - ] - ) + child: new DecoratedBox(key: key, decoration: kBoxDecoration), + ), + ], + ), ); Element box; @@ -236,15 +349,16 @@ void main() { await tester.pumpWidget( new Stack( + textDirection: TextDirection.ltr, children: [ new Positioned( right: 10.0, width: 11.0, height: 12.0, - child: new DecoratedBox(key: key, decoration: kBoxDecoration) - ) - ] - ) + child: new DecoratedBox(key: key, decoration: kBoxDecoration), + ), + ], + ), ); box = tester.element(find.byKey(key)); @@ -266,19 +380,22 @@ void main() { bool tapped; await tester.pumpWidget( - new Center( - child: new IndexedStack( - index: null, - children: [ - new GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { print("HELLO"); tapped = true; }, - child: const SizedBox( - width: 200.0, - height: 200.0, + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new IndexedStack( + index: null, + children: [ + new GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { print("HELLO"); tapped = true; }, + child: const SizedBox( + width: 200.0, + height: 200.0, + ), ), - ), - ], + ], + ), ), ), ); @@ -291,24 +408,27 @@ void main() { testWidgets('Stack clip test', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new Stack( - children: [ - new Container( - width: 100.0, - height: 100.0 - ), - new Positioned( - top: 0.0, - left: 0.0, - child: new Container( - width: 200.0, - height: 200.0 - ) - ) - ] - ) - ) + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new Stack( + children: [ + new Container( + width: 100.0, + height: 100.0, + ), + new Positioned( + top: 0.0, + left: 0.0, + child: new Container( + width: 200.0, + height: 200.0, + ), + ), + ], + ), + ), + ), ); RenderBox box = tester.renderObject(find.byType(Stack)); @@ -317,25 +437,28 @@ void main() { expect(context.invocations.first.memberName, equals(#pushClipRect)); await tester.pumpWidget( - new Center( - child: new Stack( - overflow: Overflow.visible, - children: [ - new Container( - width: 100.0, - height: 100.0 - ), - new Positioned( - top: 0.0, - left: 0.0, - child: new Container( - width: 200.0, - height: 200.0 - ) - ) - ] - ) - ) + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new Stack( + overflow: Overflow.visible, + children: [ + new Container( + width: 100.0, + height: 100.0, + ), + new Positioned( + top: 0.0, + left: 0.0, + child: new Container( + width: 200.0, + height: 200.0, + ), + ), + ], + ), + ), + ), ); box = tester.renderObject(find.byType(Stack)); @@ -347,23 +470,26 @@ void main() { testWidgets('Stack sizing: default', (WidgetTester tester) async { final List logs = []; await tester.pumpWidget( - new Center( - child: new ConstrainedBox( - constraints: const BoxConstraints( - minWidth: 2.0, - maxWidth: 3.0, - minHeight: 5.0, - maxHeight: 7.0, - ), - child: new Stack( - children: [ - new LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - logs.add(constraints.toString()); - return const Placeholder(); - }, - ), - ], + new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new ConstrainedBox( + constraints: const BoxConstraints( + minWidth: 2.0, + maxWidth: 3.0, + minHeight: 5.0, + maxHeight: 7.0, + ), + child: new Stack( + children: [ + new LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + logs.add(constraints.toString()); + return const Placeholder(); + }, + ), + ], + ), ), ), ), @@ -374,24 +500,27 @@ void main() { testWidgets('Stack sizing: explicit', (WidgetTester tester) async { final List logs = []; Widget buildStack(StackFit sizing) { - return new Center( - child: new ConstrainedBox( - constraints: const BoxConstraints( - minWidth: 2.0, - maxWidth: 3.0, - minHeight: 5.0, - maxHeight: 7.0, - ), - child: new Stack( - fit: sizing, - children: [ - new LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - logs.add(constraints.toString()); - return const Placeholder(); - }, - ), - ], + return new Directionality( + textDirection: TextDirection.ltr, + child: new Center( + child: new ConstrainedBox( + constraints: const BoxConstraints( + minWidth: 2.0, + maxWidth: 3.0, + minHeight: 5.0, + maxHeight: 7.0, + ), + child: new Stack( + fit: sizing, + children: [ + new LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + logs.add(constraints.toString()); + return const Placeholder(); + }, + ), + ], + ), ), ), ); @@ -412,27 +541,37 @@ void main() { testWidgets('Positioned.directional control test', (WidgetTester tester) async { final Key key = new UniqueKey(); - await tester.pumpWidget(new Stack( - children: [ - new Positioned.directional( - textDirection: TextDirection.rtl, - start: 50.0, - child: new Container(key: key, width: 75.0, height: 175.0), + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned.directional( + textDirection: TextDirection.rtl, + start: 50.0, + child: new Container(key: key, width: 75.0, height: 175.0), + ), + ], ), - ], - )); + ), + ); expect(tester.getTopLeft(find.byKey(key)), const Offset(675.0, 0.0)); - await tester.pumpWidget(new Stack( - children: [ - new Positioned.directional( - textDirection: TextDirection.ltr, - start: 50.0, - child: new Container(key: key, width: 75.0, height: 175.0), + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned.directional( + textDirection: TextDirection.ltr, + start: 50.0, + child: new Container(key: key, width: 75.0, height: 175.0), + ), + ], ), - ], - )); + ), + ); expect(tester.getTopLeft(find.byKey(key)), const Offset(50.0, 0.0)); }); diff --git a/packages/flutter/test/widgets/transform_test.dart b/packages/flutter/test/widgets/transform_test.dart index 928b209005..59a8341594 100644 --- a/packages/flutter/test/widgets/transform_test.dart +++ b/packages/flutter/test/widgets/transform_test.dart @@ -13,38 +13,41 @@ void main() { testWidgets('Transform origin', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Stack( - children: [ - new Positioned( - top: 100.0, - left: 100.0, - child: new Container( - width: 100.0, - height: 100.0, - color: const Color(0xFF0000FF), + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + top: 100.0, + left: 100.0, + child: new Container( + width: 100.0, + height: 100.0, + color: const Color(0xFF0000FF), + ), ), - ), - new Positioned( - top: 100.0, - left: 100.0, - child: new Container( - width: 100.0, - height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), - origin: const Offset(100.0, 50.0), - child: new GestureDetector( - onTap: () { - didReceiveTap = true; - }, - child: new Container( - color: const Color(0xFF00FFFF), + new Positioned( + top: 100.0, + left: 100.0, + child: new Container( + width: 100.0, + height: 100.0, + child: new Transform( + transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + origin: const Offset(100.0, 50.0), + child: new GestureDetector( + onTap: () { + didReceiveTap = true; + }, + child: new Container( + color: const Color(0xFF00FFFF), + ), ), ), ), ), - ), - ], + ], + ), ), ); @@ -58,38 +61,41 @@ void main() { testWidgets('Transform alignment', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Stack( - children: [ - new Positioned( - top: 100.0, - left: 100.0, - child: new Container( - width: 100.0, - height: 100.0, - color: const Color(0xFF0000FF), + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + top: 100.0, + left: 100.0, + child: new Container( + width: 100.0, + height: 100.0, + color: const Color(0xFF0000FF), + ), ), - ), - new Positioned( - top: 100.0, - left: 100.0, - child: new Container( - width: 100.0, - height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), - alignment: const FractionalOffset(1.0, 0.5), - child: new GestureDetector( - onTap: () { - didReceiveTap = true; - }, - child: new Container( - color: const Color(0xFF00FFFF), + new Positioned( + top: 100.0, + left: 100.0, + child: new Container( + width: 100.0, + height: 100.0, + child: new Transform( + transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + alignment: const FractionalOffset(1.0, 0.5), + child: new GestureDetector( + onTap: () { + didReceiveTap = true; + }, + child: new Container( + color: const Color(0xFF00FFFF), + ), ), ), ), ), - ), - ], + ], + ), ), ); @@ -102,40 +108,45 @@ void main() { testWidgets('Transform offset + alignment', (WidgetTester tester) async { bool didReceiveTap = false; - await tester.pumpWidget(new Stack( - children: [ - new Positioned( - top: 100.0, - left: 100.0, - child: new Container( - width: 100.0, - height: 100.0, - color: const Color(0xFF0000FF), - ), - ), - new Positioned( - top: 100.0, - left: 100.0, - child: new Container( - width: 100.0, - height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), - origin: const Offset(100.0, 0.0), - alignment: const FractionalOffset(0.0, 0.5), - child: new GestureDetector( - onTap: () { - didReceiveTap = true; - }, - child: new Container( - color: const Color(0xFF00FFFF), + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new Stack( + children: [ + new Positioned( + top: 100.0, + left: 100.0, + child: new Container( + width: 100.0, + height: 100.0, + color: const Color(0xFF0000FF), + ), + ), + new Positioned( + top: 100.0, + left: 100.0, + child: new Container( + width: 100.0, + height: 100.0, + child: new Transform( + transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + origin: const Offset(100.0, 0.0), + alignment: const FractionalOffset(0.0, 0.5), + child: new GestureDetector( + onTap: () { + didReceiveTap = true; + }, + child: new Container( + color: const Color(0xFF00FFFF), + ), + ), ), ), ), - ), + ], ), - ], - )); + ), + ); expect(didReceiveTap, isFalse); await tester.tapAt(const Offset(110.0, 110.0)); diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index 830772fb67..0e30ca6020 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -11,18 +11,8 @@ void main() { testWidgets('WidgetInspector smoke test', (WidgetTester tester) async { // This is a smoke test to verify that adding the inspector doesn't crash. await tester.pumpWidget( - new Stack( - children: [ - const Text('a', textDirection: TextDirection.ltr), - const Text('b', textDirection: TextDirection.ltr), - const Text('c', textDirection: TextDirection.ltr), - ], - ), - ); - - await tester.pumpWidget( - new WidgetInspector( - selectButtonBuilder: null, + new Directionality( + textDirection: TextDirection.ltr, child: new Stack( children: [ const Text('a', textDirection: TextDirection.ltr), @@ -33,6 +23,22 @@ void main() { ), ); + await tester.pumpWidget( + new Directionality( + textDirection: TextDirection.ltr, + child: new WidgetInspector( + selectButtonBuilder: null, + child: new Stack( + children: [ + const Text('a', textDirection: TextDirection.ltr), + const Text('b', textDirection: TextDirection.ltr), + const Text('c', textDirection: TextDirection.ltr), + ], + ), + ), + ), + ); + expect(true, isTrue); // Expect that we reach here without crashing. }); @@ -172,14 +178,17 @@ void main() { bool didLongPress = false; await tester.pumpWidget( - new WidgetInspector( - selectButtonBuilder: null, - child: new GestureDetector( - onLongPress: () { - expect(didLongPress, isFalse); - didLongPress = true; - }, - child: const Text('target', textDirection: TextDirection.ltr), + new Directionality( + textDirection: TextDirection.ltr, + child: new WidgetInspector( + selectButtonBuilder: null, + child: new GestureDetector( + onLongPress: () { + expect(didLongPress, isFalse); + didLongPress = true; + }, + child: const Text('target', textDirection: TextDirection.ltr), + ), ), ), ); @@ -208,27 +217,30 @@ void main() { ); } await tester.pumpWidget( - new WidgetInspector( - key: inspectorKey, - selectButtonBuilder: null, - child: new Overlay( - initialEntries: [ - new OverlayEntry( - opaque: false, - maintainState: true, - builder: (BuildContext _) => createSubtree(width: 94.0), - ), - new OverlayEntry( - opaque: true, - maintainState: true, - builder: (BuildContext _) => createSubtree(width: 95.0), - ), - new OverlayEntry( - opaque: false, - maintainState: true, - builder: (BuildContext _) => createSubtree(width: 96.0, key: clickTarget), - ), - ], + new Directionality( + textDirection: TextDirection.ltr, + child: new WidgetInspector( + key: inspectorKey, + selectButtonBuilder: null, + child: new Overlay( + initialEntries: [ + new OverlayEntry( + opaque: false, + maintainState: true, + builder: (BuildContext _) => createSubtree(width: 94.0), + ), + new OverlayEntry( + opaque: true, + maintainState: true, + builder: (BuildContext _) => createSubtree(width: 95.0), + ), + new OverlayEntry( + opaque: false, + maintainState: true, + builder: (BuildContext _) => createSubtree(width: 96.0, key: clickTarget), + ), + ], + ), ), ), );