If the file ~/local/share/{appname}/libCachedImageData.json is empty or corrupted, the function jsonDecode() throws an error, which can cause the _package cached_networkimage, for instance, to malfunction.
I have added a try-catch block as follows
try {
var json = jsonDecode(jsonString) as List<dynamic>;
for (var element in json) {
if (element is! Map<String, dynamic>) continue;
var map = element as Map<String, dynamic>;
var cacheObject = CacheObject.fromMap(map);
_jsonCache[cacheObject.id] = map;
_cacheObjects[cacheObject.key] = cacheObject;
}
} catch ( e ) {
print( "Hi there!" );
}
`
which at least tenatively works around the issue.
Expected behavior
Should properly recover from the error.
Reproduction steps
Delete ~/local/share/{appname}/libCachedImageData.json and create an empty file with
🐛 Bug Report
If the file ~/local/share/{appname}/libCachedImageData.json is empty or corrupted, the function jsonDecode() throws an error, which can cause the _package cached_networkimage, for instance, to malfunction.
I have added a try-catch block as follows
` which at least tenatively works around the issue.
Expected behavior
Should properly recover from the error.
Reproduction steps
Delete ~/local/share/{appname}/libCachedImageData.json and create an empty file with
touch ~/local/share/{appname}/libCachedImageData.json
and then run your code.
Configuration
Version: 1.x
Platform: Linux, Ubuntu 20.10.