This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
520
520
assert (_resolvedAlignment != null );
521
521
bool hasNonPositionedChildren = false ;
522
522
if (childCount == 0 ) {
523
- assert (constraints.biggest.isFinite);
524
- return constraints.biggest;
523
+ return (constraints.biggest.isFinite) ? constraints.biggest : constraints.smallest;
525
524
}
526
525
527
526
double width = constraints.minWidth;
Original file line number Diff line number Diff line change @@ -148,5 +148,30 @@ void main() {
148
148
});
149
149
});
150
150
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
+
151
176
// More tests in ../widgets/stack_test.dart
152
177
}
You can’t perform that action at this time.
0 commit comments