Skip to content

Commit 15106a9

Browse files
authored
Fix dart2wasm compilation error in Flutter 3.38+ (#1529)
1 parent 078b98b commit 15106a9

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
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);

packages/core/test/_.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ Future<String> explainWithoutPumping({
162162
).explain(built);
163163

164164
str = str.replaceAll(RegExp('String#[^,]+,'), 'String,');
165-
return str.replaceAll(RegExp('Uint8List#[0-9a-f]+,'), 'bytes,');
165+
str = str.replaceAll(RegExp('Uint8List#[0-9a-f]+,'), 'bytes,');
166+
167+
// images
168+
str = str.replaceAll(', headers: null', '');
169+
str = str.replaceAll(', webHtmlElementStrategy: never', '');
170+
171+
return str;
166172
}
167173

168174
final _explainMarginRegExp = RegExp(

0 commit comments

Comments
 (0)