findUnusedAssets method

Set<String> findUnusedAssets(
  1. List<String> allAssetPaths,
  2. Set<String> usedAssetPaths,
  3. String projectRoot
)

Identifies assets not referenced in code.

Implementation

Set<String> findUnusedAssets(
  List<String> allAssetPaths,
  Set<String> usedAssetPaths,
  String projectRoot,
) {
  final unused = <String>{};

  for (final assetPath in allAssetPaths) {
    final normalizedKey = normalizeAssetKey(assetPath, projectRoot);

    if (!usedAssetPaths.contains(normalizedKey)) {
      unused.add(assetPath);
    }
  }

  return unused;
}