evict method

Future<bool> evict(
  1. String uid
)

Evicts a single entry from DiskCache, returning true if successful.

Implementation

Future<bool> evict(String uid) async {
  if (_metadata == null) await _initMetaData();

  try {
    File normalCacheFile = File(join(
        Directory(
          join((await getTemporaryDirectory()).path, 'imagecache'),
        ).path,
        uid));

    if (_metadata!.containsKey(uid)) {
      await File(_metadata![uid]['path']).delete();
      _metadata!.remove(uid);
      await _commitMetaData();
    } else {
      await normalCacheFile.delete();
    }
    return true;
  } catch (e) {
    if (printError) print(e);
    return false;
  }
}