Skip to content

Commit 5ca9691

Browse files
committed
use if/else instead of switch statement
1 parent 078b98b commit 5ca9691

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/core/lib/src/data/build_op.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ class BuildOp {
169169
(onWidgets != null
170170
? (tree, placeholder) {
171171
final children = onWidgets(tree, [placeholder]);
172-
switch (children?.length) {
173-
case null:
174-
return placeholder;
175-
case 0:
176-
return widget0;
177-
case 1:
178-
return children?.first ?? widget0;
179-
default:
180-
throw UnsupportedError(
181-
'onWidgets must return exactly 1 widget, got ${children?.length}',
182-
);
172+
final length = children?.length;
173+
if (length == null) {
174+
return placeholder;
175+
} else if (length == 0) {
176+
return widget0;
177+
} else if (length == 1) {
178+
return children!.first;
179+
} else {
180+
throw UnsupportedError(
181+
'onWidgets must return exactly 1 widget, got $length',
182+
);
183183
}
184184
}
185185
: null);

0 commit comments

Comments
 (0)