Allow Stacks with no children or only poisitioned children

This commit is contained in:
Hans Muller
2015-10-08 10:48:33 -07:00
parent 6111301a9b
commit 3cfc9c4d95
2 changed files with 17 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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;