Skip to content

Commit 4a96608

Browse files
authored
Reland "Stop recursively including assets from asset directories" (#120312)
* stop recursively including assets from asset directories * remove unused imports * lint
1 parent 2303f42 commit 4a96608

File tree

3 files changed

+49
-16
lines changed

3 files changed

+49
-16
lines changed

packages/flutter_tools/lib/src/asset.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -909,22 +909,6 @@ class ManifestAssetBundle implements AssetBundle {
909909
attributedPackage: attributedPackage,
910910
);
911911
}
912-
913-
final Iterable<Directory> nonVariantSubDirectories = entities
914-
.whereType<Directory>()
915-
.where((Directory directory) => !_assetVariantDirectoryRegExp.hasMatch(directory.basename));
916-
for (final Directory dir in nonVariantSubDirectories) {
917-
final String relativePath = _fileSystem.path.relative(dir.path, from: assetBase);
918-
final Uri relativePathsUri = Uri.directory(relativePath, windows: _platform.isWindows);
919-
920-
_parseAssetsFromFolder(packageConfig,
921-
flutterManifest,
922-
assetBase,
923-
cache,
924-
result,
925-
relativePathsUri
926-
);
927-
}
928912
}
929913

930914
void _parseAssetFromFile(

packages/flutter_tools/test/general.shard/asset_bundle_test.dart

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,51 @@ void main() {
6969
ProcessManager: () => FakeProcessManager.any(),
7070
});
7171

72+
testUsingContext('wildcard directories do not include subdirectories', () async {
73+
globals.fs.file('.packages').createSync();
74+
globals.fs.file('pubspec.yaml').writeAsStringSync(
75+
'''
76+
name: test
77+
dependencies:
78+
flutter:
79+
sdk: flutter
80+
flutter:
81+
assets:
82+
- assets/foo/
83+
- assets/bar/lizard.png
84+
'''
85+
);
86+
87+
final List<String> assets = <String>[
88+
'assets/foo/dog.png',
89+
'assets/foo/sub/cat.png',
90+
'assets/bar/lizard.png',
91+
'assets/bar/sheep.png'
92+
];
93+
94+
for (final String asset in assets) {
95+
final File assetFile = globals.fs.file(
96+
globals.fs.path.joinAll(asset.split('/'))
97+
);
98+
assetFile.createSync(recursive: true);
99+
}
100+
101+
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
102+
await bundle.build(packagesPath: '.packages');
103+
104+
expect(bundle.entries.keys, unorderedEquals(<String>[
105+
'AssetManifest.json',
106+
'AssetManifest.bin',
107+
'FontManifest.json',
108+
'NOTICES.Z',
109+
'assets/foo/dog.png',
110+
'assets/bar/lizard.png'
111+
]));
112+
}, overrides: <Type, Generator>{
113+
FileSystem: () => testFileSystem,
114+
ProcessManager: () => FakeProcessManager.any(),
115+
});
116+
72117
testUsingContext('wildcard directories are updated when filesystem changes', () async {
73118
final File packageFile = globals.fs.file('.packages')..createSync();
74119
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);

packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ dependencies:
5454
flutter:
5555
assets:
5656
- assets/
57+
- assets/notAVariant/
58+
- assets/folder/
59+
- assets/normalFolder/
5760
'''
5861
);
5962
});
@@ -184,6 +187,7 @@ dependencies:
184187
flutter:
185188
assets:
186189
- assets/
190+
- assets/somewhereElse/
187191
'''
188192
);
189193
});

0 commit comments

Comments
 (0)