mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Treat assets as variants only if they share the same filename (#112602)
This commit is contained in:
parent
5c68452df7
commit
74dfc0708d
@ -1033,16 +1033,18 @@ class _AssetDirectoryCache {
|
||||
|
||||
final List<FileSystemEntity> entitiesInDirectory = _fileSystem.directory(directory).listSync();
|
||||
|
||||
final File assetFile = _fileSystem.file(assetPath);
|
||||
final List<String> pathsOfVariants = <String>[
|
||||
// It's possible that the user specifies only explicit variants (e.g. .../1x/asset.png),
|
||||
// so there does not necessarily need to be a file at the given path.
|
||||
if (_fileSystem.file(assetPath).existsSync())
|
||||
if (assetFile.existsSync())
|
||||
assetPath,
|
||||
...entitiesInDirectory
|
||||
.whereType<Directory>()
|
||||
.where((Directory dir) => _assetVariantDirectoryRegExp.hasMatch(dir.basename))
|
||||
.expand((Directory dir) => dir.listSync())
|
||||
.whereType<File>()
|
||||
.where((File file) => file.basename == assetFile.basename)
|
||||
.map((File file) => file.path),
|
||||
];
|
||||
|
||||
|
||||
@ -219,14 +219,18 @@ $assetsSection
|
||||
writePubspecFile(
|
||||
'p/p/pubspec.yaml',
|
||||
'test_package',
|
||||
assets: <String>['a/foo'],
|
||||
assets: <String>['a/foo', 'a/bar'],
|
||||
);
|
||||
|
||||
final List<String> assets = <String>['a/foo', 'a/2x/foo'];
|
||||
final List<String> assets = <String>['a/foo', 'a/2x/foo', 'a/bar'];
|
||||
writeAssets('p/p/', assets);
|
||||
|
||||
const String expectedManifest = '{"packages/test_package/a/foo":'
|
||||
'["packages/test_package/a/foo","packages/test_package/a/2x/foo"]}';
|
||||
const String expectedManifest = '{'
|
||||
'"packages/test_package/a/bar":'
|
||||
'["packages/test_package/a/bar"],'
|
||||
'"packages/test_package/a/foo":'
|
||||
'["packages/test_package/a/foo","packages/test_package/a/2x/foo"]'
|
||||
'}';
|
||||
|
||||
await buildAndVerifyAssets(
|
||||
assets,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user