cleanAssets static method

Future<void> cleanAssets()

Implementation

static Future<void> cleanAssets() async {
  //  Gothrough the assets directory and check if the asset is not in assetsSaved
  //  delete it
  final assetsDir = kConfig.assetsImageDir;

  if (!await assetsDir.exists()) return;

  await for (final entity in assetsDir.list()) {
    if (entity is File) {
      final fileName = p.basename(entity.path);
      if (fileName.startsWith(SlideAsset.assetPrefix)) {
        if (!assetsLoaded.contains(entity.path)) {
          await entity.delete();
        }
      }
    }
  }

  assetsLoaded.clear();
}