getImageByHash method

Future<ImageData<Object>?> getImageByHash(
  1. String hash, {
  2. bool compressed = false,
})

Implementation

Future<ImageData?> getImageByHash(String hash,
    {bool compressed = false}) async {
  if (compressed) {
    final img = await readImage(OP.convertToCompressedHashName(hash),
        cacheSize: compressed ? CACHESIZE : null);
    if (img != null) return ImageData(img, id: hash);
  }
  final img = await readImage(hash, cacheSize: compressed ? CACHESIZE : null);
  if (img == null) throw Exception("no img cached");
  // return null;

  return ImageData(img, id: hash);
}