close method

void close()

Closes this store.

Don't try to call any other ObjectBox methods after the store is closed.

Implementation

void close() {
  if (isClosed()) return;

  _boxes.values.forEach(InternalBoxAccess.close);
  _boxes.clear();

  // Call each "onClose()" event listener.
  // Move the list to prevent "Concurrent modification during iteration".
  _onClose.values.toList(growable: false).forEach((listener) => listener());
  _onClose.clear();

  _readPointers.clear();

  if (_closesNativeStore) {
    _openStoreDirectories.remove(_absoluteDirectoryPath);
    _finalizer.detach(this);
    checkObx(C.store_close(_cStore));
  }
  _cStore = nullptr;
}