Unverified Commit c1809717 authored by Bruno Leroux's avatar Bruno Leroux Committed by GitHub

Fix empty Stack with infinite constraints throws (#102642)

parent ae7fcc7e
...@@ -520,8 +520,7 @@ class RenderStack extends RenderBox ...@@ -520,8 +520,7 @@ class RenderStack extends RenderBox
assert(_resolvedAlignment != null); assert(_resolvedAlignment != null);
bool hasNonPositionedChildren = false; bool hasNonPositionedChildren = false;
if (childCount == 0) { if (childCount == 0) {
assert(constraints.biggest.isFinite); return (constraints.biggest.isFinite) ? constraints.biggest : constraints.smallest;
return constraints.biggest;
} }
double width = constraints.minWidth; double width = constraints.minWidth;
......
...@@ -148,5 +148,30 @@ void main() { ...@@ -148,5 +148,30 @@ void main() {
}); });
}); });
test('Stack in Flex can layout with no children', () {
// Render an empty Stack in a Flex
final RenderFlex flex = RenderFlex(
textDirection: TextDirection.ltr,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <RenderBox>[
RenderStack(
textDirection: TextDirection.ltr,
children: <RenderBox>[],
),
]
);
bool stackFlutterErrorThrown = false;
layout(
flex,
constraints: BoxConstraints.tight(const Size(100.0, 100.0)),
onErrors: () {
stackFlutterErrorThrown = true;
}
);
expect(stackFlutterErrorThrown, false);
});
// More tests in ../widgets/stack_test.dart // More tests in ../widgets/stack_test.dart
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment