clear method

Future<void> clear()

remove all cache entries.

Implementation

Future<void> clear() async {
  if (!_initialized) {
    await init();
  }

  if (kIsWeb) {
    if (_db != null) {
      _db!.close();
    }
    final idbFactory = getIdbFactory();

    await idbFactory!.deleteDatabase("$_basePath.db");
    _db = await idbFactory.open("$_basePath.db", version: 1,
        onUpgradeNeeded: (VersionChangeEvent event) {
      Database db = event.database;
      db.createObjectStore(_basePath);
    });
  } else {
    await Directory(_basePath).delete(recursive: true);
    await Directory(_basePath).create(recursive: true);
  }

  _timeoutMap.clear();

  await _saveMap();
}