remove method

Future<bool> remove(
  1. String key
)

remove cache entry for key

returns true if key existed and was removed. returns false if key did not exists.

Implementation

Future<bool> remove(String key) async {
  if (!_initialized) {
    await init();
  }
  _timeoutMap.remove(key);
  await _saveMap();

  if (kIsWeb) {
    if (_db == null) return false;
    var txn = _db!.transaction(_basePath, idbModeReadWrite);
    var store = txn.objectStore(_basePath);
    await store.delete(key);
    await txn.completed;
    return true;
  } else {
    final filePath = await _pathForKey(key);

    if (await FileSystemEntity.type(filePath) !=
        FileSystemEntityType.notFound) {
      await File(filePath).delete();
      return true;
    } else {
      return false;
    }
  }
}