AssetsGraph.init constructor
AssetsGraph.init(
- String hash
Initialize an assets graph, loading from cache if possible.
If the cache exists, it will be loaded. Otherwise, a new graph will be created.
A loaded graph does not mean it doesn't require invalidation. shouldInvalidate is used to determine if the cached graph is still valid.
hash is used to determine if the cached graph is still valid.
Implementation
factory AssetsGraph.init(String hash) {
if (cacheFile.existsSync()) {
try {
final dynamic cachedGraph = jsonDecode(cacheFile.readAsStringSync());
final AssetsGraph instance = AssetsGraph.fromCache(cachedGraph, hash);
if (!instance.loadedFromCache || instance.shouldInvalidate) {
Logger.info('Cache is invalid, rebuilding...');
cacheFile.deleteSync(recursive: true);
}
return instance;
} catch (e) {
Logger.info('Cache is invalid, rebuilding...');
cacheFile.deleteSync(recursive: true);
}
}
return AssetsGraph(hash);
}