From 101d4f9e7e9aa809250865cb7fdd6d7bcb28e26e Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 8 Oct 2015 10:48:33 -0700 Subject: [PATCH] Allow Stacks with no children or only poisitioned children --- sky/packages/sky/lib/src/rendering/stack.dart | 9 +++++---- sky/unit/test/widget/stack_test.dart | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/sky/packages/sky/lib/src/rendering/stack.dart b/sky/packages/sky/lib/src/rendering/stack.dart index 41484f2121f..b884d2d8760 100644 --- a/sky/packages/sky/lib/src/rendering/stack.dart +++ b/sky/packages/sky/lib/src/rendering/stack.dart @@ -172,14 +172,15 @@ abstract class RenderStackBase extends RenderBox child = parentData.nextSibling; } - if (hasNonPositionedChildren) + if (hasNonPositionedChildren) { size = new Size(width, height); - else + assert(size.width == constraints.constrainWidth(width)); + assert(size.height == constraints.constrainHeight(height)); + } else { size = constraints.biggest; + } assert(!size.isInfinite); - assert(size.width == constraints.constrainWidth(width)); - assert(size.height == constraints.constrainHeight(height)); child = firstChild; while (child != null) { diff --git a/sky/unit/test/widget/stack_test.dart b/sky/unit/test/widget/stack_test.dart index d7e9ac8afee..b075aaca930 100644 --- a/sky/unit/test/widget/stack_test.dart +++ b/sky/unit/test/widget/stack_test.dart @@ -10,6 +10,12 @@ void main() { }); }); + test('Can construct an empty Centered Stack', () { + testWidgets((WidgetTester tester) { + tester.pumpWidget(new Center(child: new Stack([]))); + }); + }); + test('Can change position data', () { testWidgets((WidgetTester tester) { Key key = new Key('container'); @@ -108,6 +114,12 @@ void main() { }); }); + test('Can construct an empty Centered IndexedStack', () { + testWidgets((WidgetTester tester) { + tester.pumpWidget(new Center(child: new IndexedStack([]))); + }); + }); + test('Can construct an IndexedStack', () { testWidgets((WidgetTester tester) { int itemCount = 3;