AssetsGraph.fromCache constructor

AssetsGraph.fromCache(
  1. Map<String, dynamic> json,
  2. String hash
)

Creates an AssetsGraph from cached JSON data.

json is the cached JSON data. hash is the current configuration hash to validate against.

Returns a new AssetsGraph populated with data from the cache.

Implementation

factory AssetsGraph.fromCache(Map<String, dynamic> json, String hash) {
  final String? lastUsedHash = json['hash'] as String?;
  final String? version = json['version'] as String?;
  final bool shouldInvalidate = lastUsedHash != hash || version != AssetsGraph.version;
  final AssetsGraph instance = AssetsGraph._fromCache(
    hash,
    shouldInvalidate: shouldInvalidate,
  );
  return AssetsScanResults.populate(instance, json);
}