Skip to content

Commit 383e2a4

Browse files
committed
remove nest code
1 parent 460e688 commit 383e2a4

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

lib/src/generators/assets_generator.dart

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,26 @@ List<_Statement> _createDirectoryClassGenStatements(
148148
isConstConstructor: true,
149149
);
150150
} else if (!child.isUnKnownMime) {
151-
for (final integration in integrations) {
152-
if (integration.mime == child.mime) {
153-
integration.isEnabled = true;
154-
statement = _Statement(
155-
type: integration.className,
156-
name: child.baseName.camelCase(),
157-
value: integration.classInstantiate(child.path),
158-
isConstConstructor: integration.isConstConstructor,
159-
);
160-
}
161-
}
162-
statement ??= _Statement(
163-
type: 'String',
164-
name: child.baseName.camelCase(),
165-
value: '\'${child.path}\'',
166-
isConstConstructor: false,
151+
final integration = integrations.firstWhere(
152+
(element) => element.mime == child.mime,
153+
orElse: () => null,
167154
);
155+
if (integration == null) {
156+
statement ??= _Statement(
157+
type: 'String',
158+
name: child.baseName.camelCase(),
159+
value: '\'${child.path}\'',
160+
isConstConstructor: false,
161+
);
162+
} else {
163+
integration.isEnabled = true;
164+
statement = _Statement(
165+
type: integration.className,
166+
name: child.baseName.camelCase(),
167+
value: integration.classInstantiate(child.path),
168+
isConstConstructor: integration.isConstConstructor,
169+
);
170+
}
168171
}
169172
return statement;
170173
})

0 commit comments

Comments
 (0)