clear method

Future<void> clear([
  1. K? key
])

Clear, delete and dispose resource by key or all resources if a key not passed.

Implementation

Future<void> clear([K? key]) => _lock.synchronized(() async {
      if (key != null) {
        final resource = _resources[key];
        if (resource != null) {
          await resource.close();
          _resources.remove(key);
        } else {
          await storage.ensureInitialized();
          await storage.delete(key);
        }
      } else {
        _resources.clear();
        await storage.clear();
      }
    });