loadAssets method

Future<List<Asset>> loadAssets({
  1. bool forTests = false,
})
inherited

Loads cached assets from the JSON file.

Implementation

Future<List<Asset>> loadAssets({bool forTests = false}) async {
  final file = JetleafPaths.assetsJson(projectRoot, forTests: forTests);
  if (!file.existsSync()) return [];

  try {
    final content = await file.readAsString();
    final List<dynamic> data = jsonDecode(content);
    return data
        .map(
          (e) => MaterialAsset(
            filePath: e['filePath'] as String,
            fileName: e['fileName'] as String,
            packageName: e['packageName'] as String,
            contentBytes: Uint8List(
              0,
            ), // Content not needed for cache metadata
          ),
        )
        .toList();
  } catch (_) {
    return [];
  }
}