Skip to content

Commit 5f4a617

Browse files
author
Ian Maciel
committed
fixup! Add support for Flutter deferred components
1 parent 564f01b commit 5f4a617

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/core/lib/generators/assets_generator.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,11 @@ List<Object> _buildAssetsList(Config config) {
5454
// We may have several deferred components, with a list of assets for each.
5555
// So before spreading the list of deferred components, we need to spread
5656
// the list of assets for each deferred component.
57-
final List<Object> deferredAssets = [];
58-
config.pubspec.flutter.deferredComponents?.forEach((deferredComponent) {
59-
// Include all manipulated assets to the list of deferred assets.
60-
deferredAssets.addAll(deferredComponent.assets ?? []);
61-
});
62-
63-
// Merge the deferred assets with the main assets.
64-
return [...config.pubspec.flutter.assets, ...deferredAssets];
57+
final deferredComponents = config.pubspec.flutter.deferredComponents ?? [];
58+
return deferredComponents.fold<List<Object>>(
59+
config.pubspec.flutter.assets,
60+
(list, deferredComponent) => list + (deferredComponent.assets ?? []),
61+
);
6562
}
6663

6764
Future<String> generateAssets(

0 commit comments

Comments
 (0)