Fix empty Stack with infinite constraints throws (#102642)
This commit is contained in:
parent
ae7fcc7e51
commit
c18097178c
@ -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() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user