File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -520,8 +520,7 @@ class RenderStack extends RenderBox
520520 assert (_resolvedAlignment != null );
521521 bool hasNonPositionedChildren = false ;
522522 if (childCount == 0 ) {
523- assert (constraints.biggest.isFinite);
524- return constraints.biggest;
523+ return (constraints.biggest.isFinite) ? constraints.biggest : constraints.smallest;
525524 }
526525
527526 double width = constraints.minWidth;
Original file line number Diff line number Diff line change @@ -148,5 +148,30 @@ void main() {
148148 });
149149 });
150150
151+ test ('Stack in Flex can layout with no children' , () {
152+ // Render an empty Stack in a Flex
153+ final RenderFlex flex = RenderFlex (
154+ textDirection: TextDirection .ltr,
155+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
156+ children: < RenderBox > [
157+ RenderStack (
158+ textDirection: TextDirection .ltr,
159+ children: < RenderBox > [],
160+ ),
161+ ]
162+ );
163+
164+ bool stackFlutterErrorThrown = false ;
165+ layout (
166+ flex,
167+ constraints: BoxConstraints .tight (const Size (100.0 , 100.0 )),
168+ onErrors: () {
169+ stackFlutterErrorThrown = true ;
170+ }
171+ );
172+
173+ expect (stackFlutterErrorThrown, false );
174+ });
175+
151176 // More tests in ../widgets/stack_test.dart
152177}
You can’t perform that action at this time.
0 commit comments