getPubspecAssetPaths method
Generates a list of pubspec asset paths based on folder indexing rules
Rules:
- If folder has subfolders: perform same operation and extend the list
- If folder does not index all: return individual file paths
- If folder indexes all: return the folder path
Returns: List of asset paths for pubspec.yaml
Example:
final assetPaths = folder.getPubspecAssetPaths();
Returns: ['assets/images/', 'assets/data/config.json', ...]
Implementation
List<String> getPubspecAssetPaths() {
final paths = <String>[];
// Get subfolders
final subfolders = children.whereType<AssetLookupFolder>().toList();
if (subfolders.isNotEmpty) {
// Has subfolders - recursively get paths from each
for (final subfolder in subfolders) {
paths.addAll(subfolder.getPubspecAssetPaths());
}
} else {
// No subfolders - check indexing rule
if (fullyIndexed) {
// Folder indexes all - return folder path with trailing slash
paths.add('$normalizedPath/');
} else {
// Folder does not index all - return individual file paths
final files = children.whereType<AssetLookupFile>();
for (final file in files) {
paths.add(file.normalizedPath);
}
}
}
return paths;
}